使用RecursiveArrayIterator导出树形结构
<?php
/**
* 使用RecursiveArrayIterator导出树形结构
* @author:PHP博客-技术-资源-技术站-面向对象
*/
$array = array(
0=>'a',
1=>array('a','b','c'),
2=>'b',
3=>array('a','b','c'),
4=>'c');
$it = new RecursiveArrayIterator($array);
print_r(iterator_to_array($it)).'<br/>';
//输出结果:Array ( [0] => a [1] => Array ( [0] => a [1] => b [2] => c )
//[2] => b [3] => Array ( [0] => a [1] => b [2] => c ) [4] => c )
?>