Voting

: min(five, three)?
(Example: nine)

The Note You're Voting On

php at mole dot gnubb dot net
21 years ago
[Editor's Note: Or just use vprintf...]
If you want to do something like <?php printf('There is a difference between %s and %s', array('good', 'evil')); ?> (this doesn't work) instead of <?php printf('There is a difference between %s and %s', 'good', 'evil'); ?> you can use this function:
<?php
function printf_array($format, $arr)
{
 return call_user_func_array('printf', array_merge((array)$format, $arr));
}
?>

Use it the following way:
<?php
$goodevil = array('good', 'evil');
printf_array('There is a difference between %s and %s', $goodevil);
?>
and it will print:
There is a difference between good and evil

<< Back to user notes page

AltStyle によって変換されたページ (->オリジナル) /