Skip to content

Instantly share code, notes, and snippets.

Created May 21, 2013 02:50
Show Gist options
  • Save anonymous/5617209 to your computer and use it in GitHub Desktop.
Save anonymous/5617209 to your computer and use it in GitHub Desktop.
<?
$p = "Съешь ещё этих мягких [block=100000] французских булок.";
$p = preg_replace_callback('/\\[([a-zA-Z]+)=([0-9]+)\\]/si', 'preg_handler', $p);
function preg_handler($matches)
{
return $matches[1]($matches[2]);
}
echo $p;
function block($a)
{
return "<br>".$a."<br>";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment