3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $data = [ 'name' => [ 'Ace', 'James', 'Tommy' ], 'age' => [ 10, 20, 32 ] ]; $newData = []; function recursivelyFormat($data) { $newData = []; if (count($data) > 0) { $name = array_shift($data['name']); $age = array_shift($data['age']); $newData[] = [ 'name' => $name, 'age' => $age ]; recursivelyFormat($data); } return $newData; } var_dump(recursivelyFormat($data)); /*for ($i = 0; $i < count($data['name']); $i++) { $d = [ 'name' => $data['name'][$i], 'age' => $data['age'][$i] ]; $newData[] = $d; } $mainData = [ 'people' => $newData ];*/ //var_dump($mainData);
based on ImjCp
Output for 7.0.0 - 7.0.6, 7.2.0
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 20480 bytes) in /in/RXgb6 on line 23
Process exited with code 255.
Output for 7.1.10

Process exited with code 137.
Output for 7.0.20 - 7.1.7
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 20480 bytes) in /in/RXgb6 on line 25
Process exited with code 255.
Output for 5.6.8 - 5.6.28
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 64 bytes) in /in/RXgb6 on line 22
Process exited with code 255.
Output for 5.5.24 - 5.5.35
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 32 bytes) in /in/RXgb6 on line 25
Process exited with code 255.
Output for 5.4.12 - 5.4.45
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 130968 bytes) in /in/RXgb6 on line 30
Process exited with code 255.
Output for 5.3.22 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/RXgb6 on line 3
Process exited with code 255.