Content Scraping with regex
Posted: Thu Oct 30, 2008 1:29 am
Below is the script that i have in place. I would like to extract 4 fields but this one only gets one. All four fields have the same matching text before and after (i.e. <div align..) How would i modify the code maybe to run a loop that run untill $num=4 or untill no more matches is found and then slip out the results?
$data = file_get_contents('http://mytestsite.htm');
$regex = '/<div align="right" class="style13">(.*?)<\/div>/';
preg_match($regex,$data,$match);
var_dump($match);
echo $match[1];