I want to read data from a remote page, and grep for a certain list of words from a list.txt file.
I looked on google and found something
<?php
$url = "
http://game.eternal-lands.com/online_players.htm";
$page = fopen($url, 'r');
$content = "";
while( !feof( $page ) ) {
$buffer = trim( fgets( $page, 4096 ) );
$content .= $buffer;
}
$start = "<Players>";
$end = "<\/Bots>";
preg_match( "/$start(.*)$end/s", $content, $match);
$mytext = $match[1];
echo "$mytext";
?>
I know almost nothing about nothing about php. I want to read
http://game.eternal-lands.com/online_players.htm mainly the Online player list and compare it to a static lists.txt file then output the matching results. Anyone can help? :)
Edit:.
I have this so far.
<?php
$link = "
http://game.eternal-lands.com/online_players.htm";
$linkcontents = file_get_contents($link);
$playerlist = strtolower($linkcontents);
$playername = "hussam";
if (strpos($playerlist, $playername) == true) {
echo "$playername";
}
?>
but now I need a loop to read an array of playername from a list.txt and use it in the php script. anyone knows how to do that?
Edit2:
google suggests
<?php
$file_handle = fopen("list.txt", "rb");
while (!feof($file_handle) ) {
$line_of_text = fgets($file_handle);
$parts = explode('=', $line_of_text);
print $parts[0] . $parts[1]. "<BR>";
}
Now I just need to find a way to plug that into the first script.