3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $userfile = array( 'name' => array ( 'everybodytalkings.jpg', 'glove.png' ), 'type' => array ( 'image/jpeg', 'image/png' ), 'tmp_name' => array ( '/home/christiant.wi8/tmp/phpNmvGeZ', '/home/christiant.wi8/tmp/phpGjsRrl' ), 'error' => array ( '0', '0' ), 'size' => array ( '65188', '75182' ), ); $new = array(); foreach($userfile as $key => $item) { $new['userfile1'][] = array($key, $item[0]); $new['userfile2'][] = array($key, $item[1]); } print_r($new);
based on AO06k
Output for 4.3.0 - 7.1.0
Array ( [userfile1] => Array ( [0] => Array ( [0] => name [1] => everybodytalkings.jpg ) [1] => Array ( [0] => type [1] => image/jpeg ) [2] => Array ( [0] => tmp_name [1] => /home/christiant.wi8/tmp/phpNmvGeZ ) [3] => Array ( [0] => error [1] => 0 ) [4] => Array ( [0] => size [1] => 65188 ) ) [userfile2] => Array ( [0] => Array ( [0] => name [1] => glove.png ) [1] => Array ( [0] => type [1] => image/png ) [2] => Array ( [0] => tmp_name [1] => /home/christiant.wi8/tmp/phpGjsRrl ) [3] => Array ( [0] => error [1] => 0 ) [4] => Array ( [0] => size [1] => 75182 ) ) )