合规国际互联网加速 OSASE为企业客户提供高速稳定SD-WAN国际加速解决方案。 广告
[TOC] ## 概述 ``` /* 方法 */ public getChildren ( ) : RecursiveArrayIterator public hasChildren ( ) : bool ``` ## 实例 ``` $myArray = array( 0 => 'a', 1 => array('subA','subB',array(0 => 'subsubA', 1 => 'subsubB', 2 => array(0 => 'deepA', 1 => 'deepB'))), 2 => 'b', 3 => array('subA','subB','subC'), 4 => 'c' ); $iterator = new RecursiveArrayIterator($myArray); iterator_apply($iterator, 'traverseStructure', array($iterator)); /** * @param RecursiveArrayIterator $iterator */ function traverseStructure($iterator) { while ( $iterator -> valid() ) { if ( $iterator -> hasChildren() ) { traverseStructure($iterator -> getChildren()); } else { echo $iterator -> key() . ' : ' . $iterator -> current() .PHP_EOL; } $iterator -> next(); } } //0 : a //0 : subA //1 : subB //0 : subsubA //1 : subsubB //0 : deepA //1 : deepB //2 : b //0 : subA //1 : subB //2 : subC //4 : c ```