I'm trying to display my array in groups of 3 elements, sorted by the last element of each group.
My array:
$info = array('goal','raul','80','foul','moneer','20','offside','ronaldo','60');
My expected output is:
1-foul moneer 20
2-offside ronaldo 60
3-goal raul 80
Sorted by the last value of the element groups.
I'm using foreach to display it:
$i = 0;
foreach($info as $key => $val) {
$i++;
echo $info[$key] . '<br>';
if ($i % 3 == 0){
echo "<br />";
}
Is this possible ? And if yes, how can I change my code to get my expected output?