3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = [ 'a' => [ 'a1' => 'a1', 'a2' => 'a2', 'a3' => 'a3', ], 'b' => [ 'b1' => 'b1', 'b2' => 'b2', 'b3' => 'b3', ], ]; $it = new RecursiveIteratorIterator(new ArrayIterator($a)); $b = []; foreach ($it as $key => $value) { $b[$key] = $value; } var_dump($b);
Output for 7.0.0 - 7.0.31, 7.1.0 - 7.1.23, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
Fatal error: Uncaught InvalidArgumentException: An instance of RecursiveIterator or IteratorAggregate creating it is required in /in/DdODR:16 Stack trace: #0 /in/DdODR(16): RecursiveIteratorIterator->__construct(Object(ArrayIterator)) #1 {main} thrown in /in/DdODR on line 16
Process exited with code 255.
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.38
Fatal error: Uncaught exception 'InvalidArgumentException' with message 'An instance of RecursiveIterator or IteratorAggregate creating it is required' in /in/DdODR:16 Stack trace: #0 /in/DdODR(16): RecursiveIteratorIterator->__construct(Object(ArrayIterator)) #1 {main} thrown in /in/DdODR on line 16
Process exited with code 255.

preferences:
250.47 ms | 402 KiB | 334 Q