Mega Code Archive

 
Categories / Php / Strings
 

Matching with preg_match_all()

<? $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); ?>