I need to replace “,” to “enoComma”, but only that located inside of brackets <…>.
I’m trying to do it like this, but it replaces only the first comma inside of the brackets
$text = 'asd, asd <asd, asd, adasd> ... ';
preg_replace_callback("/(<.*?),(.*?>)/",
create_function('$m', 'return $m[1].\'enoComma\'.$m[2];'),
$text
);
echo $text; // asd, asd <asdenoComma asd, adasd> ...
I think this should do it:
Output: