3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = Array ( "1" => Array ( "0" => "16/03/2018", "1" => "Friday", "2" => "21.00", "3" => "Friendly Match", "4" => "Italy vs France", "5" => "Truesports HD", ), "2" => Array ( "0" => "17/03/2018", "1" => "Saturday", "2" => "15.30", "3" => "Friendly Match", "4" => "Italy vs Pakistan", "5" => "Truesports HD", ), "3" => Array ( "0" => "17/03/2018", "1" => "Saturday", "2" => "19.00", "3" => "Friendly Match", "4" => "Spain vs USA", "5" => "Truesports" ) ); $array_keys= array("date","day","time","type","value","tv"); $new_array = array(); foreach ($array as $key => $value) { $tmp_array = array(); foreach ($value as $key1 => $value1) { $tmp_array[$array_keys[$key1]] = $value1; } $new_array[] =$tmp_array; } echo json_encode($new_array, JSON_PRETTY_PRINT);
Output for 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.13
[ { "date": "16\/03\/2018", "day": "Friday", "time": "21.00", "type": "Friendly Match", "value": "Italy vs France", "tv": "Truesports HD" }, { "date": "17\/03\/2018", "day": "Saturday", "time": "15.30", "type": "Friendly Match", "value": "Italy vs Pakistan", "tv": "Truesports HD" }, { "date": "17\/03\/2018", "day": "Saturday", "time": "19.00", "type": "Friendly Match", "value": "Spain vs USA", "tv": "Truesports" } ]

preferences:
79.01 ms | 409 KiB | 5 Q