PHP Matching With Preg_Match_All() – String Function

<?
$html = <<<_HTML_
<ul>
<li>BeefFun</li>
<li>Pea</li>
<li>Noodles</li>
</ul>
_HTML_;preg_match('@<li>(.*?)</li>@',$html,$matches);
$match_count = preg_match_all('@<li>(.*?)</li>@',$html,$matches_all);print "preg_match_all() matched $match_count times.\n";print "preg_match() array: ";
var_dump($matches);print "preg_match_all() array: ";
var_dump($matches_all);
?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.