PHP Snippets: Sprintf

PHPThis post is part of the PHP Snippets series where I will be covering the basics of developing in PHP.

The sprintf function provides the same functionality as the printf function, but silently.

This means you would either need to echo the output or concatenate it with a string and echo that string.

$number = 500;
$string = 'miles';

echo sprintf( 'But I would walk %d %s', $number, $string );