PHP: $this->games = ["Game1" => ["inGame", *playerobject1*, *playerobject2...], "Game2" => ["inQueue", *playerobject1*, *playerobject2*]];foreach($this->games as $game => $players){if($this->inQueue($game)){if($player instaceof Player){$players->sendMessage("Waiting for players...");}}}public function inQueue($game){if($game[0] == "inQueue"){return true;elsereturn false;} What do you think about this way to code and donyou think it will work?
It should. Tho, I would rather use PHP: public function inQueue($game){ return $game[0] === "inQueue";} than PHP: public function inQueue($game){ if($game[0] == "inQueue"){ return true; } else{ return false; }} Just saying, you had some "{" missing in your code.
Well, "if" is too. Then you still would need to close the "if" statement tho: PHP: public function inQueue($game){if($game[0] == "inQueue"){return true;}else return false;} Plus, it only works if you have one argument inside.
Read ALL Posts. He opened "if", which means he either has to close it or remove the bracket. I did not say he needs them, I just told him to close the if statement. And still, my first code actually is the easiest, so I don't know why we now have to discuss about the other one. Just use PHP: public function inQueue($game){ return $game[0] === "inQueue";}