PHP
SPL/Iterators

RecursiveArrayIterator (class)

The RecursiveArrayIterator class

Introduction

(PHP 5 >= 5.1.0, PHP 7)

This iterator allows to unset and modify values and keys while iterating over Arrays and Objects in the same way as the ArrayIterator. Additionally it is possible to iterate over the current iterator entry.

Class synopsis

RecursiveArrayIterator extends ArrayIterator implements RecursiveIterator {

/* Constants */

const integer CHILD_ARRAYS_ONLY = 4 ;

/* Methods */

public RecursiveArrayIterator getChildren ( void )

public bool hasChildren ( void )

/* Inherits */

public void ArrayIterator::append ( mixed $value )

public void ArrayIterator::asort ( void )

public ArrayIterator::__construct ([ mixed $array = array() [, int $flags = 0 ]] )

public int ArrayIterator::count ( void )

public mixed ArrayIterator::current ( void )

public array ArrayIterator::getArrayCopy ( void )

public void ArrayIterator::getFlags ( void )

public mixed ArrayIterator::key ( void )

public void ArrayIterator::ksort ( void )

public void ArrayIterator::natcasesort ( void )

public void ArrayIterator::natsort ( void )

public void ArrayIterator::next ( void )

public void ArrayIterator::offsetExists ( string $index )

public mixed ArrayIterator::offsetGet ( string $index )

public void ArrayIterator::offsetSet ( string $index , string $newval )

public void ArrayIterator::offsetUnset ( string $index )

public void ArrayIterator::rewind ( void )

public void ArrayIterator::seek ( int $position )

public string ArrayIterator::serialize ( void )

public void ArrayIterator::setFlags ( string $flags )

public void ArrayIterator::uasort ( callable $cmp_function )

public void ArrayIterator::uksort ( callable $cmp_function )

public string ArrayIterator::unserialize ( string $serialized )

public bool ArrayIterator::valid ( void )

}

Predefined Constants

RecursiveArrayIterator Flags

RecursiveArrayIterator::CHILD_ARRAYS_ONLY

Treat only arrays (not objects) as having children for recursive iteration.

Changelog

VersionDescription
5.3.0CHILD_ARRAYS_ONLY flag was added.

Table of Contents

  • RecursiveArrayIterator::getChildren — Returns an iterator for the current entry if it is an array or an object.

  • RecursiveArrayIterator::hasChildren — Returns whether current entry is an array or an object.

← ParentIterator::rewind

RecursiveArrayIterator::getChildren →

© 1997–2017 The PHP Documentation Group

Licensed under the Creative Commons Attribution License v3.0 or later.

https://secure.php.net/manual/en/class.recursivearrayiterator.php