note 71657 deleted from function.vprintf by nlopess

From: Date: Sun, 10 Dec 2006 11:21:36 +0000
Subject: note 71657 deleted from function.vprintf by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-120479@lists.php.net to get a copy of this message
Note Submitter: soylent at soylentgreens dot com ---- 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

« previous php.notes (#120479) next »