$hoth = preg_replace('<wasted time=(.*?)>/i', '[noresult]$1[/noresult]', $hoth);
I'm trying (using PHP) to replace HTML with friendlier codes (like what you'll find on most message boards) in a string. For some reason, my preg_replaces work fine for replacing <span> tags (and <b>, and most everything else) but fail to work with <div> tags.
This line works correctly, properly replacing <span style="font-style: italic;">x</span> with [i]x[/i]:
$msg = preg_replace('/<span style="font-style: italic;">(.*?)<\/span>/i', '[i]$1[/i]', $msg);
However, this line does nothing and leaves <div style="text-align: center;">x</div> untouched:
$msg = preg_replace('/<div style="text-align: center;">(.*?)<\/div>/i', '[center]$1[/center]', $msg);
I see no logical difference between the two, yet one works and the other doesn't. I've attempted some sacrificial offerings, but the gods do not seem to be moved yet. Must it be a human sacrifice before they'll make logic work for me again? |