0

i got an array like this:

    array(28) { 
[0]=> array(8) { ["jornada"]=> string(1) "1" ["team1"]=> string(12) "LEGANES F.C." ["team2"]=> string(9) "LAS CONOS" }
[1]=> array(8) { ["jornada"]=> string(1) "1" ["team1"]=> string(13) "BABACHAS F.C." ["team2"]=> string(19) "QUIRQUINCHAS VERDES" }
[2]=> array(8) { ["jornada"]=> string(1) "2" ["team1"]=> string(7) "TSU CHU" ["team2"]=> string(12) "SANTINO F.C." } 
[3]=> array(8) { ["jornada"]=> string(1) "2" ["team1"]=> string(11) "LIBERO F.C." ["team2"]=> string(9) "LAS PUMAS" } 
[4]=> array(8) { ["jornada"]=> string(1) "3" ["team1"]=> string(6) "PUCARA" ["team2"]=> string(15) "EL REJUNTE F.C." } 

my question is, how can i get the differents "jornada's" values? because i have to make a fixture grouping by "jornada" something like :

jornada 1 :
LEGANES vs LAS CONOS
BABACHAS vs QUIRQUINCHAS

jornada 2: 
TSU CHU vs SANTINO
LIBERO vs LAS PUMAS

thanks for your help and sorry about my english.

1 Answer 1

1

you could re-arrange them into a new array that has this grouping...

$grouped = array();
foreach ($data as $row) {
    $grouped[$row['jornada']][] = $row;
}

now you can do:

foreach ($grouped as $jorndada => $matches) {
    echo "Jornada $jornada\n";
    foreach ($matches as $match) {
        echo $match["team1"] ." vs ". $match["team2"] . PHP_EOL;
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.