note 107078 modified in function.strip-tags by danbrown

From: Date: Fri, 06 Jan 2012 19:16:41 +0000
Subject: note 107078 modified in function.strip-tags by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-185409@lists.php.net to get a copy of this message
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); } ?> --was-- Function to simply test if a given location index is inside a tag in the string 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); } http://php.net/manual/en/function.strip-tags.php

« previous php.notes (#185409) next »