3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $iterator = new ArrayIterator(array('recipe'=>'pancakes', 'egg', 'milk', 'flour')); var_dump($iterator); var_dump(iterator_to_array($iterator, true)); var_dump(iterator_to_array($iterator, false));
Output for 5.3.0 - 7.1.0
object(ArrayIterator)#1 (1) { ["storage":"ArrayIterator":private]=> array(4) { ["recipe"]=> string(8) "pancakes" [0]=> string(3) "egg" [1]=> string(4) "milk" [2]=> string(5) "flour" } } array(4) { ["recipe"]=> string(8) "pancakes" [0]=> string(3) "egg" [1]=> string(4) "milk" [2]=> string(5) "flour" } array(4) { [0]=> string(8) "pancakes" [1]=> string(3) "egg" [2]=> string(4) "milk" [3]=> string(5) "flour" }
Output for 5.2.1 - 5.2.17
object(ArrayIterator)#1 (4) { ["recipe"]=> string(8) "pancakes" [0]=> string(3) "egg" [1]=> string(4) "milk" [2]=> string(5) "flour" } array(4) { ["recipe"]=> string(8) "pancakes" [0]=> string(3) "egg" [1]=> string(4) "milk" [2]=> string(5) "flour" } array(4) { [0]=> string(8) "pancakes" [1]=> string(3) "egg" [2]=> string(4) "milk" [3]=> string(5) "flour" }
Output for 5.1.0 - 5.2.0
object(ArrayIterator)#1 (4) { ["recipe"]=> string(8) "pancakes" [0]=> string(3) "egg" [1]=> string(4) "milk" [2]=> string(5) "flour" } Warning: iterator_to_array() expects exactly 1 parameter, 2 given in /in/YRI6n on line 4 bool(false) Warning: iterator_to_array() expects exactly 1 parameter, 2 given in /in/YRI6n on line 5 bool(false)
Output for 5.0.0 - 5.0.5
object(ArrayIterator)#1 (4) { ["recipe"]=> string(8) "pancakes" [0]=> string(3) "egg" [1]=> string(4) "milk" [2]=> string(5) "flour" } Fatal error: Call to undefined function iterator_to_array() in /in/YRI6n on line 4
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: arrayiterator in /in/YRI6n on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: arrayiterator in /in/YRI6n on line 2