Unable to use regex to search in PHP?

Uweyppkadl

New Member
I'm trying to get the code of a html document in specific tags.My method works for some tags, but not all, and it not work for the tag's content I want to get.Here is my code:\[code\]<html><head></head><body><?php $url = "http://sf.backpage.com/MusicInstruction/"; $data = http://stackoverflow.com/questions/3651315/file_get_contents($url); $pattern ="/<div class=\"cat\">(.*)<\/div>/"; preg_match_all($pattern, $data, $adsLinks, PREG_SET_ORDER); var_dump($adsLinks); foreach ($adsLinks as $i) { echo "<div class='ads'>".$i[0]."</div>"; } ?></body></html>\[/code\]The above code doesn't work, but it works when I change the $pattern into:\[code\]$pattern = "/<div class=\"date\">(.*)<\/div>/";\[/code\]or\[code\]$pattern = "/<div class=\"sponsorBoxPlusImages\">(.*)<\/div>/";\[/code\]I can't see any different between these $pattern. Please help me find the error.Thanks.
 
Back
Top