3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php /*** an array of animal ***/ $animals = array( array('type'=>'dog', 'name'=>'butch', 'sex'=>'m', 'breed'=>'boxer'), array('type'=>'dog', 'name'=>'fido', 'sex'=>'m', 'breed'=>'doberman'), array('type'=>'dog', 'name'=>'girly','sex'=>'f', 'breed'=>'poodle'), array('type'=>'cat', 'name'=>'tiddles','sex'=>'m', 'breed'=>'ragdoll'), array('type'=>'cat', 'name'=>'tiddles','sex'=>'f', 'breed'=>'manx'), array('type'=>'cat', 'name'=>'tiddles','sex'=>'m', 'breed'=>'maine coon'), array('type'=>'horse', 'name'=>'ed','sex'=>'m', 'breed'=>'clydesdale'), array('type'=>'perl_coder', 'name'=>'shadda','sex'=>'none', 'breed'=>'mongrel'), array('type'=>'duck', 'name'=>'galapogus','sex'=>'m', 'breed'=>'pekin') ); /*** create a new recursive array iterator ***/ $iterator =new RecursiveArrayIterator(new ArrayObject($animals)); /*** traverse the $iterator object ***/ while($iterator->valid()) { echo $iterator->key().' -- '.$iterator->current().'<br/>'; $iterator->next(); } ?>
based on rSGTk
Output for 5.4.0 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
Notice: Array to string conversion in /in/RqGQ5 on line 20 0 -- Array<br/> Notice: Array to string conversion in /in/RqGQ5 on line 20 1 -- Array<br/> Notice: Array to string conversion in /in/RqGQ5 on line 20 2 -- Array<br/> Notice: Array to string conversion in /in/RqGQ5 on line 20 3 -- Array<br/> Notice: Array to string conversion in /in/RqGQ5 on line 20 4 -- Array<br/> Notice: Array to string conversion in /in/RqGQ5 on line 20 5 -- Array<br/> Notice: Array to string conversion in /in/RqGQ5 on line 20 6 -- Array<br/> Notice: Array to string conversion in /in/RqGQ5 on line 20 7 -- Array<br/> Notice: Array to string conversion in /in/RqGQ5 on line 20 8 -- Array<br/>
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.1.0 - 5.3.29
0 -- Array<br/>1 -- Array<br/>2 -- Array<br/>3 -- Array<br/>4 -- Array<br/>5 -- Array<br/>6 -- Array<br/>7 -- Array<br/>8 -- Array<br/>
Output for 5.0.0 - 5.0.5
Fatal error: Class 'RecursiveArrayIterator' not found in /in/RqGQ5 on line 16
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: recursivearrayiterator in /in/RqGQ5 on line 16
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: recursivearrayiterator in /in/RqGQ5 on line 16