lundi 24 juillet 2017

filter objects in two seperate subject foreach if

I have a question. I am trying to filter a match game. In the match game I want to filter the players ...but because there is a home and away team ....I want to seperate them. How is this possible.

So far I got this.

$Players = [];
                    foreach($Match->Players as $playerItem) {
                    $Players[] = $playerItem->Name . ' ' . $playerItem->Team;
                } 
         if ($playerItem->Team == "G"){
        echo implode(', ', $Players); } 
        else {
    echo " ";
}

can someone help me on this subject thanx!

Aucun commentaire:

Enregistrer un commentaire