$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];
Content Scraping with regex
Moderator: General Moderators
Content Scraping with regex
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?
Re: Content Scraping with regex
Use preg_match_all(). 
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Re: Content Scraping with regex
Thanx alot man. it worked but still one issue.. There are four results and i want them to each be in their own $variable. Here are the current results:
array(2) { [0]=> array(4) { [0]=> string(102) "
R2,356.15
" [1]=> string(58) "
R5,890.37
" [2]=> string(86) "
R117.81
" [3]=> string(47) "
R39.31
" } [1]=> array(4) { [0]=> string(61) "R2,356.15 " [1]=> string(17) "R5,890.37 " [2]=> string(45) "R117.81 " [3]=> string(6) "R39.31" } }
Re: Content Scraping with regex
Code: Select all
$var1 = $matches[0][0];
$var2 = $matches[0][1];
$var3 = ...