note 71656 added to function.printf
| From: | soylentatsoylentgreensdotcom at osu1 dot php dot net | Date: | Sun, 10 Dec 2006 10:07:57 +0000 |
| Subject: | note 71656 added to function.printf | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-120473@lists.php.net to get a copy of this message | ||
and of course I've already updated it:
<?
/* printf_arrays(string format[, mixed args[, mixed...]]) */
function printf_arrays($format) {
$args = func_get_args();
array_shift($args); // get rid of format
$longest = 0;
foreach($args as $arg) {
if(is_array($arg) && count($arg) > $longest)
$longest = count($arg);
}
for($i=0; $i<$longest; $i++) {
$pfargs = Array();
foreach($args as $arr) $pfargs[] = is_array($arr) ? ( isset($arr[$i]) ? $arr[$i] : '' )
: $arr;
vprintf($format, $pfargs);
}
}
?>
allows you to mix and match:
printf_arrays('%s is %s', $names, 'cool');
bob is cool
ted is cool
sue is cool
----
Server IP: 64.71.164.2
Probable Submitter: 66.140.222.27
----
Manual Page -- http://www.php.net/manual/en/function.printf.php
Edit -- https://master.php.net/note/edit/71656
Del: integrated -- https://master.php.net/note/delete/71656/integrated
Del: useless -- https://master.php.net/note/delete/71656/useless
Del: bad code -- https://master.php.net/note/delete/71656/bad+code
Del: spam -- https://master.php.net/note/delete/71656/spam
Del: non-english -- https://master.php.net/note/delete/71656/non-english
Del: in docs -- https://master.php.net/note/delete/71656/in+docs
Del: other reasons-- https://master.php.net/note/delete/71656
Reject -- https://master.php.net/note/reject/71656
Search -- https://master.php.net/manage/user-notes.php