3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $keyArray = array("clientId","clientName","clientAdsress","clientPhone"); $valuesArray = array( "0"=>array("1001","aaaaa","ddddddd","22222222"), "1"=>array("1002","bbbbbb","ddddddd","11111111"), "2"=>array("1003","ccccc","ddddddd","33333333") ); $expected = array( "clientId"=>array("1001","1002","1003"), "clientName"=>array("aaaaa","bbbbbb","ccccc"), "clientAdsress"=>array("ddddddd","ddddddd","ddddddd"), "clientPhone"=>array("22222222","11111111","33333333") ); $result = []; foreach($keyArray as $key => $keyName) { foreach($valuesArray as $value) { $result[$keyName][] = $value[$key]; } } var_dump($result === $expected);
Output for 7.1.25 - 7.3.2
bool(true)