note 77775 deleted from function.preg-replace-callback by felipe
| From: | felipe@php.net | Date: | Mon, 10 Dec 2007 02:24:21 +0000 |
| Subject: | note 77775 deleted from function.preg-replace-callback by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-133108@lists.php.net to get a copy of this message | ||
Note Submitter: ak at optimumenglish dot com
----
Add this snippet to your callback function to make sure you don't replace HTML code. Useful
when searching / replacing / highlighting HTML. Change 90 to whatever threshold you need if you have
extra extra long tags for some weird reason (lots of inline styles?)
function scanForTags($position, $maintext)
{
for($i = 1;$i < 90; $i++)
{
if($maintext{$position-$i} == "<" || $maintext{$position+$i} == ">")
return true;
if($maintext{$position-$i} == ">" || $maintext{$position+$i} == "<")
return false;
}
return false;
}