Parsing Information

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
SidewinderX
Forum Contributor
Posts: 407
Joined: Fri Jul 16, 2004 9:04 pm
Location: NY

Parsing Information

Post by SidewinderX »

Ive already built an 'engine' that parses information from this website https://www.novaworld.com/Players/Stats ... 1&p=616065. In an effort to just get the script done i used any code that i could find that worked.

here is a snippet of my current code

Code: Select all

$url = "https://www.novaworld.com/Players/Stats.aspx?id=33680801261&p=616065";
$content = file_get_contents($url); 
$strip = strip_tags($content);
$remove = stristr($strip, 'Down');
$stats = $remove;
$pcid = stristr($stats, 'PCID:');
sscanf($pcid, 'PCID: %s' , $pcid);
echo "PCID: " . $pcid . "<br>";
essentially what the code above does is it gets the content of the url, strips the html, gets rid of all the information upto "Down" then starts parsing the data using scanf and storing it as a variable.

the code above gets the job done, but i was wondering if there any alternatives to get the job done that are maybe safer, faster, or better

im open to suggestions - thank you
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

There has got to be a regex that can do that for you.
Post Reply