mirror of
https://github.com/php/php-gtk-src.git
synced 2026-03-24 17:22:10 +01:00
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
16 lines
297 B
PHP
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);
|
|
}
|
|
?>
|