3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php // define nested array $data = array("United States",array("Texas", "Philadelphia"),array("California",array ("Los Angeles", "San Francisco"))); // initialize an Iterator // pass it the array to be processed $iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($data)); // iterate over the array // result: "UNITED STATES TEXAS PHILADELPHIA CALIFORNIA LOS ANGELES SAN FRANCISCO" foreach ($iterator as $value) { print strtoupper($value) . " <br>"; }
Output for 5.1.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
UNITED STATES <br>TEXAS <br>PHILADELPHIA <br>CALIFORNIA <br>LOS ANGELES <br>SAN FRANCISCO <br>
Output for 5.0.0 - 5.0.5
Fatal error: Class 'RecursiveArrayIterator' not found in /in/SMBKN on line 11
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: recursiveiteratoriterator in /in/SMBKN on line 11
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: recursiveiteratoriterator in /in/SMBKN on line 11