/ Published in: PHP

Taken from stackoverflow answer by user Jon
To test
$foo = array('age' => 5, 'name' => 'john');
echo vsprintf_named("%(name)s is %(age)02d", $foo);
To test
$foo = array('age' => 5, 'name' => 'john');
echo vsprintf_named("%(name)s is %(age)02d", $foo);
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function vsprintf_named($format, $args) { foreach($matches as $match) { $values[] = $args[$match[1]]; } }
URL: http://stackoverflow.com/questions/7435233/name-php-specifiers-in-printf-strings
Comments
