3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ 'lala' => 123, 'lulu' => [ 'foo' => 'bar', 'wurs' => [ 'erdbaer', 'kaese' ] ], 'err' => [ 'da' => [ 'fuq' => 'yaye' ] ] ]; $it = new RecursiveArrayIterator($arr); $func = function(RecursiveArrayIterator $it) { while ($it->valid()) { $it->next(); } } iterator_apply($it, $func, [$it]); echo '<pre>' . __FILE__ . ' on line ' . __LINE__ . PHP_EOL; print_r($it->getArrayCopy()); exit;
Output for 7.1.0 - 7.1.14, 7.2.0 - 7.2.2
Parse error: syntax error, unexpected 'iterator_apply' (T_STRING) in /in/tB4jW on line 26
Process exited with code 255.

preferences:
165.11 ms | 1395 KiB | 25 Q