Jump to content

Searching an auto generated list


al3x8730

Recommended Posts

I have an auto generated list using the cURL function, this is organized within a table.

 

<?php
$test = file_get_contents('http://game.endless-online.com/playerlist.html');
//echo $test;
preg_match_all('|<td width="155"><font face="Arial" size="2" color ="#111111">\s+(.*?)</font>\s+</td><td width="155"><font face="Arial" size="2" color ="#111111">\s+(.*?)</font>\s+</td><td width="50"><font face="Arial" size="2" color ="#111111">\s+(.*?)</font>\s+</td><td width="100"><font face="Arial" size="2" color ="#111111">\s+(.*?)</font>\s+</td><td width="70"><font face="Arial" size="2" color ="#111111">\s+(.*?)</font>\s+</td>|is',$test, $out);
echo '<table><tr><td><b><u>Name</u></b></td><td><b><u>Title</u></b></td><td><b><u>Level</u></b></td><td><b><u>Experience</u><b/></td><td><b><u>Gender</u></b></td></tr>';
foreach ($out[0] as $k => $v){
echo '<tr><td>', $out[1][$k], '</td><td>', $out[2][$k], '</td><td>', $out[3][$k], '</td><td>', $out[4][$k], '</td><td>',$out[5][$k], "</td></tr>";
}
echo '</table>';
?>

 

That works fine. But now I want to add a search feature to it somewhat like this:

 

if (strstr($data, $online)) {
echo $online." is online!";

} else {

echo $online." is not online.";

}

 

Where $online = A user input name. So they can enter a username, and if it's on that auto generated list it will echo $online." is online."; Or not...

 

But I'm having trouble editing the first code so I can get this working. I'm trying to get the echo of the data into a variable $data so then using the search function I can just use what I have posted above.

 

Can anyone help?

Link to comment
https://forums.phpfreaks.com/topic/123191-searching-an-auto-generated-list/
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.