I know the printf statement in PHP can format strings as follows:
//my variable
$car = "BMW X6";
printf("I drive a %s",$car); // prints I drive a BMW X6,
However, when I try to print an array using printf, there does not seem to be a way to format it. Can anyone help?
Here’s an extract from one of the comments on http://php.net/manual/en/function.printf.php:
[Editor’s Note: Or just use vprintf…]
If you want to do something like:
Instead of
You can use this function:
Use it the following way:
And it will print: