note 20261 deleted from function.preg-match-all by sniper
| From: | sniper@php.net | Date: | Tue, 30 Sep 2003 12:22:43 +0000 |
| Subject: | note 20261 deleted from function.preg-match-all by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-57432@lists.php.net to get a copy of this message | ||
Note Submitter:
----
Made a change to Chris' above code:
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;
}
Notably this line:
$preg="/<".$tag.".*?>(.*?)<\/".$tag.">/si";
You can now use the above to search for tags that have additional info in them (<a href...>,
etc).