- var_dump: documentation ( source)
- preg_replace_callback: documentation ( source)
- preg_replace: documentation ( source)
<?php
class x
{
public $a = [
'~.~' => '$this->waa($0);'
];
function p($s)
{
foreach($this->a as $p => $r)
{
$s = preg_replace_callback($p, function($m) use ($s){
$c = preg_replace('~\$(\d)~', '$m[$1]', $s);
print "\n$c\n";
return eval($c);
}, $s);
}
return $s;
}
function waa($t){ return '*'.$t.'*'; }
}
var_dump((new x)->p('wazup'));