- preg_replace: documentation ( source)
<?php
function replaceSingleQuotesInsideTags( $input )
{
$output = preg_replace('/<[^>]*>/e', "str_replace(\"'\", \"\\\"\", '$0')", $input);
echo $output;
}
replaceSingleQuotesInsideTags("On <A href='/home/' target='_self'>this</Apage you will find <SPAN STYLE='font-style: italic'>stuff</SPAN>");
?>