Jump to content

preg_match help


Lethal323

Recommended Posts

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?

 

Link to comment
https://forums.phpfreaks.com/topic/186665-preg_match-help/
Share on other sites

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.

 

 

Link to comment
https://forums.phpfreaks.com/topic/186665-preg_match-help/#findComment-985940
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.