3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = Array ( "0" => Array ( "0" => "Name", "1" => "Company", "2" => "Email", "3" => "City", ), "1" => Array ( "0" => "Foo", "1" => "Foo & co", "2" => "foo@mail.com", "3" => "NY", ), "2" => Array ( "0" => "Bar", "1" => "Bar & co", "2" => "bar@mail.com", "3" => "Las Vegas", ) ); $final_result = array(); foreach($array as $key=>$value){ if($key == 0){ $final_result = array_values($value); }else{ $result[]= array_combine($final_result, array_values($value)); } } echo "<pre>"; print_r($result); ?>
Output for 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
<pre>Array ( [0] => Array ( [Name] => Foo [Company] => Foo & co [Email] => foo@mail.com [City] => NY ) [1] => Array ( [Name] => Bar [Company] => Bar & co [Email] => bar@mail.com [City] => Las Vegas ) )

preferences:
51.91 ms | 408 KiB | 5 Q