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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.