note 63143 added to function.printf
| From: | php at iain dot nl | Date: | Tue, 14 Mar 2006 15:24:36 +0000 |
| Subject: | note 63143 added to function.printf | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-105790@lists.php.net to get a copy of this message | ||
for arrays, there is vprintf();
alternatively, if you have it all in one array (including the format), this will do the trick:
<?php
$goodevil = array ('There is a difference between %s and %s', 'good',
'evil');
echo vprintf(array_shift($goodevil),$goodevil);
?>
and without mangling your array, you might use call_user_func_array:
<?php
$goodevil = array ('There is a difference between %s and %s', 'good',
'evil');
echo call_user_func_array('sprintf',$goodevil);
?>
----
Server IP: 83.137.20.120
Probable Submitter: 82.134.132.149
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.printf.php
Edit -- http://master.php.net/note/edit/63143
Del: integrated -- http://master.php.net/note/delete/63143/integrated
Del: useless -- http://master.php.net/note/delete/63143/useless
Del: bad code -- http://master.php.net/note/delete/63143/bad+code
Del: spam -- http://master.php.net/note/delete/63143/spam
Del: non-english -- http://master.php.net/note/delete/63143/non-english
Del: in docs -- http://master.php.net/note/delete/63143/in+docs
Del: other reasons-- http://master.php.net/note/delete/63143
Reject -- http://master.php.net/note/reject/63143
Search -- http://master.php.net/manage/user-notes.php