How to use PHP preg_replace regular expression to find and replace text
- by Roger
I wrote this PHP code to make some substitutions:
function cambio($txt){
$from=array(
'/\+\>([^\+\>]+)\<\+/', //finds +>text<+
'/\%([^\%]+)\%/', //finds %text%
);
$to=array(
'<span class="P">\1</span>',
'<span>\1</span>',
);
return…