3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $input['links']["link"] = ["onet.pl", "wp.pl"]; $input['links']["title"] = ["Link 1", "Link 2"]; function rebuildArray($input) { foreach($input['links'] as $key => $value) { $index = 0; foreach($value as $value2) { $arr2[$index++][$key]=$value2; } } $output['links'] = $arr2; return $output; } var_dump(rebuildArray($input));
based on pvaXB
Output for 5.5.0 - 7.3.0rc4
array(1) { ["links"]=> array(2) { [0]=> array(2) { ["link"]=> string(7) "onet.pl" ["title"]=> string(6) "Link 1" } [1]=> array(2) { ["link"]=> string(5) "wp.pl" ["title"]=> string(6) "Link 2" } } }