I have a script that’s fetching a page from a site using cURL and im trying to cut it up row by row then extracting what i need and removing that row. The problem is, sometimes it will give me the correct position of an item and sometimes it wont depending on what row, it alternates.
im trying to use one of these pages: http://www.gametracker.com/search/
the code im using is:
while (strpos($contents, '<tr>'))
{
$start = strpos($contents, '<tr>');
$end = strpos($contents, '</tr>', $start) + 5;
$rstring = substr($contents, $start, $end - $start);
$contents = str_replace($rstring, '', $contents);
//nameee
$start = strpos($rstring, '[clantag]');
$end = strpos($rstring, '</a>', $start);
$name= trim(substr($rstring, $start, $end - $start));
echo $name . '<br/>';
//players
$search = '<td class="c05 item_bgcolor_even">';
$start = (strpos($rstring, $search) + strlen($search));
$end = strpos($rstring, "</td>", $start);
$players= trim(substr($rstring, $start, ($end - $start)));
echo $players . '<br />';
$map;
$curPlayers;
$maxPlayers;
$ip;
}
It gets the server name correctly but when it comes to players, one line i get them and the other I get lor_odd”> 1230.
It’s going to be way easier with a DOM parser:
Outputs: