3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $array = array( array('pear', 'apple'), array('banana', 'coconut'), 'orange' // This is not an array element ); foreach ($array as $value) { // Check type of element... if (is_array($value)) { foreach ($value as $fruit) { echo $fruit . PHP_EOL; } } else { echo $value . PHP_EOL; } } $iterator = new RecursiveArrayIterator($array); foreach(new RecursiveIteratorIterator($iterator) as $value) { echo $value . PHP_EOL; }
based on YaPU8
Output for 5.1.0 - 7.1.0
pear apple banana coconut orange pear apple banana coconut orange
Output for 5.0.2 - 5.0.5
pear apple banana coconut orange Fatal error: Class 'RecursiveArrayIterator' not found in /in/W93SC on line 22
Process exited with code 255.
Output for 5.0.0 - 5.0.1
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/W93SC on line 14 pearPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/W93SC on line 14 applePHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/W93SC on line 14 bananaPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/W93SC on line 14 coconutPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/W93SC on line 17 orangePHP_EOL Fatal error: Class 'RecursiveArrayIterator' not found in /in/W93SC on line 22
Process exited with code 255.
Output for 4.3.10 - 4.4.9
pear apple banana coconut orange Fatal error: Cannot instantiate non-existent class: recursivearrayiterator in /in/W93SC on line 22
Process exited with code 255.
Output for 4.3.2 - 4.3.9
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/W93SC on line 14 pearPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/W93SC on line 14 applePHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/W93SC on line 14 bananaPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/W93SC on line 14 coconutPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/W93SC on line 17 orangePHP_EOL Fatal error: Cannot instantiate non-existent class: recursivearrayiterator in /in/W93SC on line 22
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/W93SC on line 14 pearPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/W93SC on line 14 applePHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/W93SC on line 14 bananaPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/W93SC on line 14 coconutPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/W93SC on line 17 orangePHP_EOL Fatal error: Cannot instantiate non-existent class: recursivearrayiterator in /in/W93SC on line 22