Well,
That partially solved the problem.
I now have
<span style='font-size:24px;' style='color:blue;'>This is extra large blue text</span>
and it only recognises the contents of the first style attribute.
So I mucked around and added:
$msg = preg_replace("/style='(.*?)\' style='(.*?)\'/si","style='\\1\\2'",$msg);
to combine the contents of the style attribute which produced:
<span style='font-size:24px;color:blue;'>This is extra large blue text</span>
I used this to get it work for more than 2 span tags:
while (true)
{
$tmp_msg = $msg;
$search = array('#<span(\s[^>]*)><span(\s[^>]*)>#i','#</span></span>#i');
$replace = array('<span\\1\\2>','</span>');
$msg = preg_replace($search, $replace, $msg);
$msg = preg_replace("/style='(.*?)\' style='(.*?)\'/si","style='\\1\\2'",$msg);
if ($msg == $tmp_msg)
break; // if no replacement has been done (i.e. strings match), break out of the loop
}
Thanks for RegExp(ertise) NogDog 😃