Jump to content

Reading Certain Lines


Solar

Recommended Posts

Hello Everyone, I hope this is possible which probably is 100%.

 

I want to make a quick easy little script that takes the master server list of a game and list certain players.

 

Lets say for Example; 6 people are in a game server, there is.. Noob_Player1, Noob_Player2, Noob_Player3, Person1, Person2, Person3.

 

fopen(); is what I am using to open the simple file which just is the IP of the Server, Name of the Server, Port of the Server, Server Version, and Players in the server.

 

Is there a way to filter players in the server to show only people that start with "Noob_"

I've tried searching on the php website for fopen codes and I can't seem to find the right one I am looking for.

 

Heres an example of something I have started, it gets the rank, player, and score.

  <table border="1" cellpadding="5" cellspacing="1" bordercolor="#0099FF" id="tablerounds">
    <tbody>
      <tr>
        <th>Rank</th>
    <th>Player</th>
    <th>Points</th>
    </tr>
      <?php $fp = @fopen("HIGHSCORES.txt", "rb")
or die("Couldn't open file"); $data = ""; while(!feof($fp)) {
$data .= fgets($fp, 1024); } fclose($fp);
$values = explode("\n", $data);
$run=(count($values))-1; $x=0;
while($x<18){
echo "<tr><td style=\"color: rgb(192, 192, 192);\">" .($x+1). "</td><td style=\"color: rgb(192, 192, 192);\">" . substr($values[$x],9) . "</td><td style=\"color: rgb(192, 192, 192);\">". substr($values[$x],0, . "</td></tr>"; $x++; }
?>
    </tbody>
  </table>

 

Thanks In advance!

Link to comment
https://forums.phpfreaks.com/topic/162088-reading-certain-lines/
Share on other sites

THanks But. I recieve error.

Fatal error: Maximum execution time of 60 seconds exceeded in C:\xampp\htdocs\servers.php on line 17

 

  <div align="center"><br><table border="1" cellpadding="5" cellspacing="1" bordercolor="#0099FF" id="tablerounds">
    <tbody>
      <tr>
    <th>Player</th>
    </tr>
      <?php 
  $fp = @fopen("URLHERE", "rb")
or die("Couldn't open file"); $data = ""; while(!feof($fp)) {
$data .= fgets($fp, 1024); } fclose($fp);
$values = explode("\n", $data);
$run=(count($values))-1; $x=0;
{
while($x<100)
substr($values[$x],9) == '-=}ID<'. "</td><td style=\"color: rgb(192, 192, 192);\">". 
substr($values[$x],0,. "</td></tr>"; $x++; }
?>

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.