0

I am creating a website using PHP where it shows top lithuanian minecraft servers and their player count. Unfortunately, I've run into a problem whereas one of the servers gives me the wrong player amount. My solution to that was to use their "official" site and get the part of the website where it says how many people are currently online, this is the code that I have now for that:

$content = file_get_contents($url);
$first_step = explode( '<font size="4" face="tahoma">' , $content );
$second_step = explode("</font>" , $first_step[1] );

And I got an error saying:

Notice: Undefined offset: 1 in C:\wamp64\www\index.php on line 212

Can't figure it out on my own, so I thought maybe you can help.

Ecofg
  • 35
  • 5
  • Dump out first step, this will have only 1 element. Look at your explode resulted.. var_dump($first_step) – Wimanicesir May 04 '20 at 10:10
  • I would recommend looking into using something like [DOMDocument](https://www.php.net/manual/en/class.domdocument.php) to fetch the information from a downloaded HTML string. Currently, if they would change the font or it's size, your code would stop working. – M. Eriksson May 04 '20 at 10:14
  • Thank's for the suggestion, seems like I did it wrong, it explodes just the part and just leaves the entire website, not just the player count. – Ecofg May 04 '20 at 10:17

0 Answers0