karp@karp:~/tmp/php/1$ php -v
PHP 5.3.10-1ubuntu3.6 with Suhosin-Patch (cli) (built: Mar 11 2013 14:31:48)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
karp@karp:~/tmp/php/1$ hhvm --version
HipHop VM v2.0.2 (rel)
Compiler: tags/HPHP-2.0.2-0-ga3803ffa8aab6dd582af9f6e28bb8878954310dd
Repo schema: c9334168ca1d6fbba2f465f1bdf1e96e0e53b0cf
karp@karp:~/tmp/php/1$ cat recursiveiteratoriterator-getdepth.php
<?php
$tree = array();
$tree[1][2][3] = 'lemon';
$tree[1][4] = 'melon';
$tree[2][3] = 'orange';
$tree[2][5] = 'grape';
$tree[3] = 'pineapple';
print_r($tree);
$arrayiter = new RecursiveArrayIterator($tree);
$iteriter = new RecursiveIteratorIterator($arrayiter);
foreach ($iteriter as $key => $value) {
$d = $iteriter->getDepth();
echo "depth=$d k=$key v=$value\n";
}
?>
karp@karp:~/tmp/php/1$ php recursiveiteratoriterator-getdepth.php
Array
(
[1] => Array
(
[2] => Array
(
[3] => lemon
)
[4] => melon
)
[2] => Array
(
[3] => orange
[5] => grape
)
[3] => pineapple
)
depth=2 k=3 v=lemon
depth=1 k=4 v=melon
depth=1 k=3 v=orange
depth=1 k=5 v=grape
depth=0 k=3 v=pineapple
karp@karp:~/tmp/php/1$ hhvm recursiveiteratoriterator-getdepth.php
Array
(
[1] => Array
(
[2] => Array
(
[3] => lemon
)
[4] => melon
)
[2] => Array
(
[3] => orange
[5] => grape
)
[3] => pineapple
)
HipHop Fatal error: Undefined class: RecursiveArrayIterator in /home/karp/tmp/php/1/recursiveiteratoriterator-getdepth.php on line 11
following code produces error: