3v4l.org

run code in 300+ PHP versions simultaneously
<?php // extend the RecursiveIteratorIterator class ULRows extends RecursiveIteratorIterator { function __construct($it) { // here we use the parent class and use LEAVES_ONLY to parent::__construct($it, self::LEAVES_ONLY); } function beginChildren() { echo '<ul>'; } function endChildren() { echo '</ul>' . "\n"; } } /** * * 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 RecursiveIteratorIterator(new RecursiveArrayIterator(new ArrayIterator($animals))); /** * * traverse the $iterator object ** */ while ( $iterator->valid() ) { var_dump($iterator->current()); echo "<li>" . $iterator->current() . '</li>'; $iterator->next(); } ?>
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of ULRows::beginChildren() should either be compatible with RecursiveIteratorIterator::beginChildren(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/jj1Rh on line 11 Deprecated: Return type of ULRows::endChildren() should either be compatible with RecursiveIteratorIterator::endChildren(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/jj1Rh on line 15 array(4) { ["type"]=> string(3) "dog" ["name"]=> string(5) "butch" ["sex"]=> string(1) "m" ["breed"]=> string(5) "boxer" } Warning: Array to string conversion in /in/jj1Rh on line 44 <li>Array</li>string(3) "dog" <li>dog</li>string(5) "butch" <li>butch</li>string(1) "m" <li>m</li>string(5) "boxer" <li>boxer</li>string(3) "dog" <li>dog</li>string(4) "fido" <li>fido</li>string(1) "m" <li>m</li>string(8) "doberman" <li>doberman</li>string(3) "dog" <li>dog</li>string(5) "girly" <li>girly</li>string(1) "f" <li>f</li>string(6) "poodle" <li>poodle</li>string(3) "cat" <li>cat</li>string(7) "tiddles" <li>tiddles</li>string(1) "m" <li>m</li>string(7) "ragdoll" <li>ragdoll</li>string(3) "cat" <li>cat</li>string(7) "tiddles" <li>tiddles</li>string(1) "f" <li>f</li>string(4) "manx" <li>manx</li>string(3) "cat" <li>cat</li>string(7) "tiddles" <li>tiddles</li>string(1) "m" <li>m</li>string(10) "maine coon" <li>maine coon</li>string(5) "horse" <li>horse</li>string(2) "ed" <li>ed</li>string(1) "m" <li>m</li>string(10) "clydesdale" <li>clydesdale</li>string(10) "perl_coder" <li>perl_coder</li>string(6) "shadda" <li>shadda</li>string(4) "none" <li>none</li>string(7) "mongrel" <li>mongrel</li>string(4) "duck" <li>duck</li>string(9) "galapogus" <li>galapogus</li>string(1) "m" <li>m</li>string(5) "pekin" <li>pekin</li>

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
46.79 ms | 405 KiB | 8 Q