...

View Full Version : Resolved Parser is invalid



UrbanTwitch
09-06-2009, 05:51 AM
Hi there, does this seem right?


<?php

$file = file_get_contents("http://minecraft.net");

preg_match("/<div id=\"links\">(.*?)<br\/>/", $file, $post);


echo "MC Stats: $post[0] <br />";
?>

Doesn't work... I get the error:


Notice: Undefined offset: 0 in C:\wamp\www\crafthub\stats\stats.php on line 8
MC Stats:

Ok now go to: http://minecraft.net. Then view source and go to <div id="links"> etc... Well, how do I grab that? I am doing it wrong (hence the error). Can anyone help me?

Thanks.

Zangeel
09-06-2009, 06:42 AM
Regex sucks don't it:



<?php
$file = file_get_contents("http://minecraft.net");

preg_match("/<div id=\"links\">(.+?)<\/div>/si", $file, $post);

echo "MC Stats: $post[0] <br />";
?>


Should work out for ya.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum