ArrayIterator 类
(PHP 5, PHP 7, PHP 8)
简介
允许在遍历 arrays 或 objects 时删除元素,修改键或值。
要多次迭代同一个数组,建议实例化 ArrayObject 并使用
ArrayIterator 实例,当使用 foreach 隐式创建时,可以迭代内部存储的数组,
或者通过手动调用 ArrayObject::getIterator() 方法创建一个。
类摘要
/* 常量 */
/* 方法 */
}预定义常量
ArrayIterator 标记
ArrayIterator::STD_PROP_LIST-
当以列表形式访问对象时(例如 var_dump()、
foreach等),对象的属性将具有正常的功能。 ArrayIterator::ARRAY_AS_PROPS-
可以通过属性访问条目(读写都支持)。
目录
- ArrayIterator::append — Append an element
- ArrayIterator::asort — Sort entries by values
- ArrayIterator::__construct — Construct an ArrayIterator
- ArrayIterator::count — Count elements
- ArrayIterator::current — Return current array entry
- ArrayIterator::getArrayCopy — Get array copy
- ArrayIterator::getFlags — Get behavior flags
- ArrayIterator::key — Return current array key
- ArrayIterator::ksort — Sort entries by keys
- ArrayIterator::natcasesort — Sort entries naturally, case insensitive
- ArrayIterator::natsort — Sort entries naturally
- ArrayIterator::next — Move to next entry
- ArrayIterator::offsetExists — Check if offset exists
- ArrayIterator::offsetGet — Get value for an offset
- ArrayIterator::offsetSet — Set value for an offset
- ArrayIterator::offsetUnset — Unset value for an offset
- ArrayIterator::rewind — Rewind array back to the start
- ArrayIterator::seek — Seeks to a position
- ArrayIterator::serialize — Serialize
- ArrayIterator::setFlags — Set behaviour flags
- ArrayIterator::uasort — Sort with a user-defined comparison function and maintain index association
- ArrayIterator::uksort — Sort by keys using a user-defined comparison function
- ArrayIterator::unserialize — Unserialize
- ArrayIterator::valid — Check whether array contains more entries