<?php $results = array ( 0 => array ( "punti" => 418, "vittorie" => 9, "podi" => 18, "gv" => 14, "id_pilota" => 1, "team" => "Red Bull Racing", "naz" => "it" ), 1 => array ( "punti" => 353, "vittorie" => 6, "podi" => 16, "gv" => 3, "id_pilota" => 19, "team" => "Scuderia Ferrari", "naz" => "it" ), 2 => array ( "punti" => 335, "vittorie" => 4, "podi" => 15, "gv" => 1, "id_pilota" => 5, "team" => "Mercedes-AMG", "naz" => "it" ), 3 => array ( "punti" => 181, "vittorie" => 1, "podi" => 5, "gv" => 1, "id_pilota" => 2, "team" => "Mercedes-AMG", "naz" => "it" ), 4 => array ( "punti" => 147, "vittorie" => 0, "podi" => 3, "gv" => 0, "id_pilota" => 14, "team" => "Racing Point F1", "naz" => "mx" ), 5 => array ( "punti" => 127, "vittorie" => 0, "podi" => 0, "gv" => 0, "id_pilota" => 13, "team" => "Haas F1", "naz" => "dk" ) ); $teams = array(); foreach ($results as $result) { $team = $result['team']; if (!isset($teams[$team])) { $teams[$team] = array('team' => $team, 'points' => $result['punti']); } else { $teams[$team]['points'] += $result['punti']; } } $teams = array_values($teams); print_r($teams);
You have javascript disabled. You will not be able to edit any code.
Value for `_results` contains invalid data `array`