Home > Backend Development > PHP Tutorial > 关于RecursiveIteratorIterator几个参数测试结果

关于RecursiveIteratorIterator几个参数测试结果

WBOY
Release: 2016-06-23 14:00:30
Original
2227 people have browsed it

手册文档对这几个参数注释全部为空,要自写程序测试……唉

看名字就知道,RecursiveIteratorIterator是个递归迭代器,其后可选带四个参数(只能任一)

RecursiveIteratorIterator::LEAVES_ONLY
默认,已在__construct中设定使用
作用是去枝留叶,跳过空节点,只递归取实值
举例就是
1.递归文件夹取文件时跳过文件夹本身,只取文件夹下面的文件,输出的项全部是file(文件和各级子文件夹的文件)
2.多维数组就跳过前几维的key,而取value,输出的每一项都不是array
3.XML只取值(text),不输出节点名,当然还要视乎你设定获取xml什么内容

RecursiveIteratorIterator::SELF_FIRST
各项都包含,例如递归文件夹就会连同子文件夹名称也作为其中项输出,顺序是先父后子

RecursiveIteratorIterator::CHILD_FIRST
同上,但顺序是先子后父,./test/test.php会在./test(文件夹)前面

RecursiveIteratorIterator::CATCH_GET_CHILD
未明,测试结果和LEAVES_ONLY一样,估计是只取子项,例如二级元素包含实值和三级元素时只取下级元素?
谁知道的这个来补充一下



另外,唠叨,上次的问题知道正确的写法了,递归函数写在类里面要用RecursiveCallbackFilterIterator这个


回复讨论(解决方案)

呃,来个人接分啊,我好结贴……

http://www.kittencup.com/standard-php-library-%E8%BF%AD%E4%BB%A3%E5%99%A8-recursiveiteratoriterator/

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template