note 107078 deleted from function.strip-tags by aharvey
| From: | aharvey@php.net | Date: | Thu, 20 Sep 2012 12:16:12 +0000 |
| Subject: | note 107078 deleted from function.strip-tags by aharvey | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-190930@lists.php.net to get a copy of this message | ||
Note Submitter: Cubist
----
Function to simply test if a given location index is inside a tag in the string
<?php
function in_tag($str,$index) {
//test if $index occurs inside an html tag in $str
$before = substr($str,0,$index);
$after = substr($str,$index);
$prev_lt = strrpos($before,'<');
$next_lt = strpos($after,'<') + $index;
$prev_gt = strrpos($before,'>');
$next_gt = strpos($after,'>') + $index;
return ($prev_gt < $prev_lt) && ($next_lt > $next_gt);
}
?>