Lethal323 Posted December 30, 2009 Share Posted December 30, 2009 Im trying to pull my folding@home stats from a website. I am using preg_match to search the data I pulled from the webpage. However I get the result of "NULL" whenever I try to run it! <?php $data = file_get_contents('http://folding.extremeoverclocking.com/user_summary.php?s=&u=454083'); $regex = "/<td align='right'> (.+?) </td> /"; preg_match($regex,$data,$match); var_dump($match); echo $match[1]; ?> Anybody know what is wrong? Quote Link to comment https://forums.phpfreaks.com/topic/186665-preg_match-help/ Share on other sites More sharing options...
dreamwest Posted December 30, 2009 Share Posted December 30, 2009 $src = file_get_contents('http://folding.extremeoverclocking.com/user_summary.php?s=&u=454083'); preg_match_all('~<td align\s?=\s?[\'"]right[\'"]>(.*?)</td>~is', $src, $c); foreach ($c[1] as $a) { echo "{$a}"; } Quote Link to comment https://forums.phpfreaks.com/topic/186665-preg_match-help/#findComment-985874 Share on other sites More sharing options...
oni-kun Posted December 30, 2009 Share Posted December 30, 2009 Well, I wouldn't recommend using foreach, Try this sample code: $src = file_get_contents('http://folding.extremeoverclocking.com/user_summary.php?s=&u=454083'); preg_match_all('~<td align\s?=\s?[\'"]right[\'"]>(.*?)</td>~is', $src, $contents); echo "<pre>"; //For formatting echo print_r($contents); That will give you a better idea of the structure of what you're retrieving, as you see, there are a lot of table lines and a lot of elements that tag will give you. Quote Link to comment https://forums.phpfreaks.com/topic/186665-preg_match-help/#findComment-985940 Share on other sites More sharing options...
salathe Posted December 30, 2009 Share Posted December 30, 2009 When developing, always turn up your error reporting (and be sure to have display_errors as on!) to the fullest extent. Then, the (first) problem would become apparent. Quote Link to comment https://forums.phpfreaks.com/topic/186665-preg_match-help/#findComment-986142 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.