3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $input = array ( "group_name_1" => "audi", "group_locations_1" => "tokyo,barcelona,paris", "group_quantities_at_locations_1" => "1,2,7", "group_name_2" => "ford", "group_locations_2" => "london,prag", "group_quantities_at_locations_2" => "3,6" ); $result = []; $function = function($v) use (&$result){ $result[$v[0]] = array_combine(explode(",",$v[1]),explode(",",$v[2])); }; array_walk(array_chunk($input,3),$function); print_r($result);
based on sRd1f
Output for 7.0.0 - 7.2.0
Notice: Only variables should be passed by reference in /in/eTjtp on line 17 Array ( [audi] => Array ( [tokyo] => 1 [barcelona] => 2 [paris] => 7 ) [ford] => Array ( [london] => 3 [prag] => 6 ) )
Output for hhvm-3.10.1 - 3.17.3
Array ( [audi] => Array ( [tokyo] => 1 [barcelona] => 2 [paris] => 7 ) [ford] => Array ( [london] => 3 [prag] => 6 ) )
Output for 5.5.0 - 5.6.30
Strict Standards: Only variables should be passed by reference in /in/eTjtp on line 17 Array ( [audi] => Array ( [tokyo] => 1 [barcelona] => 2 [paris] => 7 ) [ford] => Array ( [london] => 3 [prag] => 6 ) )