On the server I get a list of files. Of these, I get the maximum number of players and the number of players who are currently playing. So I need to get from these files the greatest value of the number of players who are currently playing. Thanks Here is the code. There all functions

foreach ($this->pg->arenas as $var) { $maxplayer = $var->getSlot(); $players = $var->getSlot(true); $ev->getPlayer()->sendMessage($var->getWorld().": ".$maxplayer."/".$players); } 
  • What are the difficulties? - Anton Shchyrov
  • And where is the code that shows how you get the number of players who play? - Visman
  • With a comparison ... - Anonim Anonim

1 answer 1

 $maxplayers = -1; foreach ($this->pg->arenas as $var) { $maxplayer = $var->getSlot(); $players = $var->getSlot(true); if ($players > $maxplayers) $maxplayers = $players; $ev->getPlayer()->sendMessage($var->getWorld().": ".$maxplayer."/".$players); } echo $maxplayers; 
  • I need not the maximum value of the number of players, but the largest value of the $ players variable - Anonim Anonim
  • @AnonimAnonim Ie you cannot modify the given code by yourself? Ok, I'll do it for you - Anton Shchyrov