note 51763 added to function.printf

From: Date: Sun, 10 Apr 2005 13:15:52 +0000
Subject: note 51763 added to function.printf
Groups: php.notes 
Request: Send a blank email to php-notes+get-87785@lists.php.net to get a copy of this message
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 ---- Manual Page -- http://www.php.net/manual/en/function.printf.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+51763 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51763&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51763&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51763&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51763&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51763&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+51763&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#87785) next »