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); }
Output for 5.1.0 - 5.6.21, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
UNITED STATESTEXASPHILADELPHIACALIFORNIALOS ANGELESSAN FRANCISCO
Output for 5.0.0 - 5.0.5
<br /> <b>Fatal error</b>: Class 'RecursiveArrayIterator' not found in <b>/in/GXIc5</b> on line <b>11</b><br />
Process exited with code 255.
Output for 4.3.2 - 4.4.9
<br /> <b>Fatal error</b>: Cannot instantiate non-existent class: recursiveiteratoriterator in <b>/in/GXIc5</b> on line <b>11</b><br />
Process exited with code 255.
Output for 4.3.0 - 4.3.1
<br /> <b>Fatal error</b>: Cannot instantiate non-existent class: recursiveiteratoriterator in <b>/in/GXIc5</b> on line <b>11</b><br />