3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<? $arData = array( 0 => array( 'number' => '+934543534' ), 1 => array( 'carrier' => 'plumber' ), 2 => array( 'number' => '+3253245235' ), 3 => array( 'carrier' => 'police' ), 4 => array( 'number' => '+11113534' ), 5 => array( 'carrier' => 'banker' ) ); $arResult = array(); foreach ($arData as $key => $arValue) { $arResult[intval($key/2)][key($arValue)] = $arValue[key($arValue)]; } print_r($arResult); ?>
based on nhCFG
Output for 5.4.0 - 5.6.28, hhvm-3.10.0 - 3.13.2, 7.0.0 - 7.1.0
Array ( [0] => Array ( [number] => +934543534 [carrier] => plumber ) [1] => Array ( [number] => +3253245235 [carrier] => police ) [2] => Array ( [number] => +11113534 [carrier] => banker ) )
Output for 4.3.0 - 5.3.29
<? $arData = array( 0 => array( 'number' => '+934543534' ), 1 => array( 'carrier' => 'plumber' ), 2 => array( 'number' => '+3253245235' ), 3 => array( 'carrier' => 'police' ), 4 => array( 'number' => '+11113534' ), 5 => array( 'carrier' => 'banker' ) ); $arResult = array(); foreach ($arData as $key => $arValue) { $arResult[intval($key/2)][key($arValue)] = $arValue[key($arValue)]; } print_r($arResult); ?>