3v4l.org

run code in 300+ PHP versions simultaneously
<?php var_export( iterator_to_array([1,2,3]) );
Output for 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
array ( 0 => 1, 1 => 2, 2 => 3, )
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28
Fatal error: Uncaught TypeError: iterator_to_array(): Argument #1 ($iterator) must be of type Traversable, array given in /in/aPVBt:4 Stack trace: #0 /in/aPVBt(4): iterator_to_array(Array) #1 {main} thrown in /in/aPVBt on line 4
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33
Fatal error: Uncaught TypeError: Argument 1 passed to iterator_to_array() must implement interface Traversable, array given in /in/aPVBt:4 Stack trace: #0 /in/aPVBt(4): iterator_to_array(Array) #1 {main} thrown in /in/aPVBt on line 4
Process exited with code 255.
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
Catchable fatal error: Argument 1 passed to iterator_to_array() must implement interface Traversable, array given in /in/aPVBt on line 4
Process exited with code 255.

preferences:
178.96 ms | 402 KiB | 183 Q