I have the The similar text:
"Eat [ 12 ] my [ 15] shorts [ 20 ]"
And I would like to remove whitespace from all brackets in string.
I tried something like:
$str = 'Eat [ 12 ] my [ 15] shorts [ 20 ]';
$str = preg_replace_callback("~\([^\)]*)\)~", function($s) {
return str_replace(" ", "", "($s[1])");
}, $str);
echo $str;
But still without succes.
Could somebody tell my, how to do this right way please?
Many thanks for any help.