Files
php-gtk-src/generator/array_printf.php
Elizabeth M Smith 4cda109cf9 This officially breaks building with anything less then 5.3
with the generator since it uses closures

But I can't get rid the of the /e modifier in the regex
without using a closure to wrap up that array information
so I'm stuck - either I break the generator for 5.2
or it spews on 5.4

Note this doesn't mean you can't still build against 5.2
you just need php 5.3 cli or higher to do the build
2012-08-08 23:07:37 -04:00

16 lines
297 B
PHP

<?php
function aprintf($tmpl, $array)
{
$array = (array)$array;
if (count($array) < 1) return $tmpl;
$callback =
function ($matches) use ($array)
{
return isset($array[$matches[1]]) ? $array[$matches[1]] : "";
};
return preg_replace_callback('!%\((\w+)\)!', $callback, $tmpl);
}
?>