note 17411 deleted from function.preg-match-all by victor
| From: | victor@php.net | Date: | Wed, 04 Dec 2002 11:05:11 +0000 |
| Subject: | note 17411 deleted from function.preg-match-all by victor | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-40331@lists.php.net to get a copy of this message | ||
I came up with this small function to get the content of all specified tags in a string, quite handy
sometimes...
/*
Function untag($string,$tag,mode){
written by Chris Heilmann (info@onlinetools.org)
filters the content of tag $tag from $string
when mode is 1 the content gets returned as an array
otherwise as a string
*/
function untag($string,$tag,$mode){
$tmpval="";
$preg="/<".$tag.">(.*?)<\/".$tag.">/si";
preg_match_all($preg,$string,$tags);
foreach ($tags[1] as $tmpcont){
if ($mode==1){$tmpval[]=$tmpcont;}
else {$tmpval.=$tmpcont;}
}
return $tmpval;
}