3v4l.org

run code in 300+ PHP versions simultaneously
<?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);
Output for 8.2.12 - 8.2.17, 8.3.0 - 8.3.4
Fatal error: Out of memory (allocated 31457280 bytes) (tried to allocate 20480 bytes) in /in/RXgb6 on line 23 mmap() failed: [12] Cannot allocate memory mmap() failed: [12] Cannot allocate memory
Process exited with code 255.
Output for 8.1.25 - 8.1.27
Fatal error: Out of memory (allocated 31457280) (tried to allocate 20480 bytes) in /in/RXgb6 on line 22 mmap() failed: [12] Cannot allocate memory mmap() failed: [12] Cannot allocate memory
Process exited with code 255.
Output for 7.4.0
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 262144 bytes) in /in/RXgb6 on line 21
Process exited with code 255.
Output for 7.3.0 - 7.3.12
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 20480 bytes) in /in/RXgb6 on line 22
Process exited with code 255.
Output for 7.0.0 - 7.0.13, 7.2.0 - 7.2.3, 7.2.7 - 7.2.25
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 5.6.31 - 5.6.33, 7.2.4 - 7.2.6

Process exited with code 137.
Output for 7.0.14 - 7.0.33, 7.1.0 - 7.1.33
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.0 - 5.6.30, 5.6.34 - 5.6.40
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 32 bytes) in /in/RXgb6 on line 22
Process exited with code 255.
Output for 5.5.0 - 5.5.38
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 32 bytes) in /in/RXgb6 on line 19
Process exited with code 255.

preferences:
186.82 ms | 401 KiB | 207 Q