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)]; } echo '<pre>'; print_r($arResult); echo '</pre>'; ?>
based on J3Paq
Output for 5.4.34 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
<pre>Array ( [0] => Array ( [number] => +934543534 [carrier] => plumber ) [1] => Array ( [number] => +3253245235 [carrier] => police ) [2] => Array ( [number] => +11113534 [carrier] => banker ) ) </pre>
Output for 4.3.0 - 5.4.32
<? $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)]; } echo '<pre>'; print_r($arResult); echo '</pre>'; ?>