I tried a simple regex using preg_replace_callback
as
$str = 'Key Value';
$str = preg_replace_callback('/(key) (.*?)/', function($m) {
return $m[2].$m[1];
}, $str);
echo $str;
I expected the output would be
ValueKey
but it doesn't. Where did I make the mistake?