cvs: php-src /ext/spl/tests iterator_015.phpt

From: Date: Thu, 04 Nov 2004 22:07:18 +0000
Subject: cvs: php-src /ext/spl/tests iterator_015.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-29132@lists.php.net to get a copy of this message
helly Thu Nov 4 17:07:18 2004 EDT Added files: /php-src/ext/spl/tests iterator_015.phpt Log: - Add new test http://cvs.php.net/co.php/php-src/ext/spl/tests/iterator_015.phpt?r=1.1&p=1 Index: php-src/ext/spl/tests/iterator_015.phpt +++ php-src/ext/spl/tests/iterator_015.phpt --TEST-- SPL: RecursiveIteratorIterator and beginChildren/endChildren --FILE-- <?php class RecursiveArrayIterator extends ArrayIterator implements RecursiveIterator { function hasChildren() { return is_array($this->current()); } function getChildren() { return new RecursiveArrayIterator($this->current()); } } class RecursiveArrayIteratorIterator extends RecursiveIteratorIterator { function rewind() { echo "<ul>\n"; parent::rewind(); } function beginChildren() { echo str_repeat(' ',$this->getDepth())."<ul>\n"; } function endChildren() { echo str_repeat(' ',$this->getDepth()+1)."</ul>\n"; } function valid() { if (!parent::valid()) { echo "<ul>\n"; return false; } return true; } } $arr = array("a", array("ba", array("bba", "bbb"), array(array("bcaa"))), array("ca"), "d"); $obj = new RecursiveArrayIterator($arr); $rit = new RecursiveArrayIteratorIterator($obj); foreach($rit as $k=>$v) { echo str_repeat(' ',$rit->getDepth()+1)."$k=>$v\n"; } ?> ===DONE=== <?php exit(0); ?> --EXPECTF-- <ul> 0=>a <ul> 0=>ba <ul> 0=>bba 1=>bbb </ul> <ul> <ul> 0=>bcaa </ul> </ul> </ul> <ul> 0=>ca </ul> 3=>d <ul> ===DONE===

« previous php.cvs (#29132) next »