3v4l.org

run code in 300+ PHP versions simultaneously
<?php $foo = array('foo', 'bar'); var_dump(iterator_to_array($foo));
Output for 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
array(2) { [0]=> string(3) "foo" [1]=> string(3) "bar" }
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/OFAcS:6 Stack trace: #0 /in/OFAcS(6): iterator_to_array(Array) #1 {main} thrown in /in/OFAcS on line 6
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 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/OFAcS:6 Stack trace: #0 /in/OFAcS(6): iterator_to_array(Array) #1 {main} thrown in /in/OFAcS on line 6
Process exited with code 255.
Output for 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.28
Catchable fatal error: Argument 1 passed to iterator_to_array() must implement interface Traversable, array given in /in/OFAcS on line 6
Process exited with code 255.

preferences:
220.85 ms | 402 KiB | 244 Q