RegexIterator匹配和修改迭代器的数据集
<?php
/**
* 初定义数组...
* @author:PHP博客-技术-资源-技术站-面向对象
*/
$array = array('apple','avocado','orange','pineapple');
/**
* 创建迭代器
*/
$arrIterator = new ArrayIterator($array);
/**
* 使用正则表达式模式来匹配和修改迭代器的数据
*/
$iterator = new RegexIterator($arrIterator,'/^a/');
print_r(iterator_to_array($iterator));
/**
* 输出结果:Array ( [0] => apple [1] => avocado )
*/
?>