3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array ( 'EVENTNAME' => array ( 0 => 'Brexit', 1 => 'leave date set', 2 => 'leave date ', 3 => 'deal or no deal', ), 'IMMIGRATIONS' => array ( 0 => '1', 1 => '1', 2 => '1', 3 => '1', ), 'EFFECTS' => array ( 0 => '2', 1 => '1', 2 => '1', 3 => '2', ), 'SUPPLYCHAINS' => array ( 0 => '1', 1 => '1', 2 => '1', 3 => '1', ), ); $keys = array_keys($arr); foreach($arr[$keys[0]] as $key => $val){ $result[$val] = array_column(array_slice($arr,1), $key); } var_export($result);
Output for 7.1.25 - 7.1.27, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.13
array ( 'Brexit' => array ( 0 => '1', 1 => '2', 2 => '1', ), 'leave date set' => array ( 0 => '1', 1 => '1', 2 => '1', ), 'leave date ' => array ( 0 => '1', 1 => '1', 2 => '1', ), 'deal or no deal' => array ( 0 => '1', 1 => '2', 2 => '1', ), )

preferences:
60.85 ms | 408 KiB | 5 Q