note 20261 added to function.preg-match-all

From: Date: Thu, 28 Mar 2002 00:55:48 +0000
Subject: note 20261 added to function.preg-match-all
Groups: php.notes 
Request: Send a blank email to php-notes+get-28310@lists.php.net to get a copy of this message
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). -- http://www.php.net/manual/en/function.preg-match-all.php http://master.php.net/manage/user-notes.php?action=edit+20261 http://master.php.net/manage/user-notes.php?action=delete+20261 http://master.php.net/manage/user-notes.php?action=reject+20261

« previous php.notes (#28310) next »