Skip to content

Latest commit

 

History

History
15 lines (8 loc) · 419 Bytes

415_str_vsprintf.md

File metadata and controls

15 lines (8 loc) · 419 Bytes

Format a string with an array: vsprintf()

The function vsprinf() is similar to sprintf(), the difference is that vsprintf accepts an array of arguments, rather than a variable number of arguments (sprintf).

$parameters = ['John', 25];
$string = vsprintf('Hi %s, you are %d years old. Good bye my friend %1$s', $parameters);
echo $string . PHP_EOL;

The format rules are the same for sprintf().