IteratorsTable of Contents
SPL provides a set of iterators to traverse over objects. SPL Iterators Class Tree
The AppendIterator classIntroductionAn Iterator that iterates over several iterators one after the other. Class synopsisAppendIterator
class AppendIterator
extends
IteratorIterator
implements
OuterIterator
{
/* Methods */
public
__construct
( void
)
public void append
( Iterator
$iterator
)
public mixed current
( void
)
public void getArrayIterator
( void
)
public Iterator getInnerIterator
( void
)
public int getIteratorIndex
( void
)
public scalar key
( void
)
public void next
( void
)
public void rewind
( void
)
public bool valid
( void
)
/* Inherited methods */
public IteratorIterator::__construct
( Traversable
$iterator
)
public mixed IteratorIterator::current
( void
)
public Traversable IteratorIterator::getInnerIterator
( void
)
public scalar IteratorIterator::key
( void
)
public void IteratorIterator::next
( void
)
public void IteratorIterator::rewind
( void
)
public bool IteratorIterator::valid
( void
)
}The ArrayIterator classIntroductionThis iterator allows to unset and modify values and keys while iterating over Arrays and Objects. When you want to iterate over the same array multiple times you need to instantiate ArrayObject and let it create ArrayIterator instances that refer to it either by using foreach or by calling its getIterator() method manually. Class synopsisArrayIterator
class ArrayIterator
implements
ArrayAccess
,
SeekableIterator
,
Countable
,
Serializable
{
/* Methods */
public void append
( mixed
$value
)
public void asort
( void
)
public __construct
([ mixed
$array = array()
[, int $flags = 0
]] )
public int count
( void
)
public mixed current
( void
)
public array getArrayCopy
( void
)
public void getFlags
( void
)
public mixed key
( void
)
public void ksort
( void
)
public void natcasesort
( void
)
public void natsort
( void
)
public void next
( void
)
public void offsetExists
( string
$index
)
public mixed offsetGet
( string
$index
)
public void offsetSet
( string
$index
, string $newval
)
public void offsetUnset
( string
$index
)
public void rewind
( void
)
public void seek
( int
$position
)
public string serialize
( void
)
public void setFlags
( string
$flags
)
public void uasort
( string
$cmp_function
)
public void uksort
( string
$cmp_function
)
public string unserialize
( string
$serialized
)
public bool valid
( void
)
}The CachingIterator classIntroductionThis object supports cached iteration over another iterator. Class synopsisCachingIterator
class CachingIterator
extends
IteratorIterator
implements
OuterIterator
,
ArrayAccess
,
Countable
{
/* Constants */
const
integer
CachingIterator::CALL_TOSTRING
= 1
;
const
integer
CachingIterator::CATCH_GET_CHILD
= 16
;
const
integer
CachingIterator::TOSTRING_USE_KEY
= 2
;
const
integer
CachingIterator::TOSTRING_USE_CURRENT
= 4
;
const
integer
CachingIterator::TOSTRING_USE_INNER
= 8
;
const
integer
CachingIterator::FULL_CACHE
= 256
;
/* Methods */
public __construct
( Iterator
$iterator
[, string $flags = self::CALL_TOSTRING
] )
public int count
( void
)
public void current
( void
)
public void getCache
( void
)
public void getFlags
( void
)
public Iterator getInnerIterator
( void
)
public void hasNext
( void
)
public scalar key
( void
)
public void next
( void
)
public void offsetExists
( string
$index
)
public void offsetGet
( string
$index
)
public void offsetSet
( string
$index
, string $newval
)
public void offsetUnset
( string
$index
)
public void rewind
( void
)
public void setFlags
( bitmask
$flags
)
public void __toString
( void
)
public void valid
( void
)
}Predefined Constants
The CallbackFilterIterator classIntroduction
Class synopsisCallbackFilterIterator
class CallbackFilterIterator
extends
FilterIterator
implements
OuterIterator
{
/* Methods */
public
__construct
( Iterator
$iterator
, callable $callback
)
public string accept
( void
)
/* Inherited methods */
public
abstract
bool FilterIterator::accept
( void
)
public
FilterIterator::__construct
( Iterator
$iterator
)
public mixed FilterIterator::current
( void
)
public Iterator FilterIterator::getInnerIterator
( void
)
public mixed FilterIterator::key
( void
)
public void FilterIterator::next
( void
)
public void FilterIterator::rewind
( void
)
public bool FilterIterator::valid
( void
)
}ExamplesThe callback should accept up to three arguments: the current item, the current key and the iterator, respectively. Example #1 Available callback arguments
<?php Any callable may be used; such as a string containing a function name, an array for a method, or an anonymous function. Example #2 Callback basic examples
<?php The DirectoryIterator classIntroductionThe DirectoryIterator class provides a simple interface for viewing the contents of filesystem directories. Class synopsisDirectoryIterator
class DirectoryIterator
extends
SplFileInfo
implements
SeekableIterator
{
/* Methods */
public __construct
( string
$path
)
public DirectoryIterator current
( void
)
public int getATime
( void
)
public
string
getBasename
([
string
$suffix
] )
public int getCTime
( void
)
public string getExtension
( void
)
public string getFilename
( void
)
public int getGroup
( void
)
public int getInode
( void
)
public int getMTime
( void
)
public int getOwner
( void
)
public string getPath
( void
)
public string getPathname
( void
)
public int getPerms
( void
)
public int getSize
( void
)
public string getType
( void
)
public bool isDir
( void
)
public bool isDot
( void
)
public bool isExecutable
( void
)
public bool isFile
( void
)
public bool isLink
( void
)
public bool isReadable
( void
)
public bool isWritable
( void
)
public string key
( void
)
public void next
( void
)
public void rewind
( void
)
public
void
seek
( int
$position
)
public
string
__toString
( void
)
public bool valid
( void
)
}Changelog
The EmptyIterator classIntroductionThe EmptyIterator class for an empty iterator. Class synopsisEmptyIterator
class EmptyIterator
implements
Iterator
{
/* Methods */
public void current
( void
)
public void key
( void
)
public void next
( void
)
public void rewind
( void
)
public void valid
( void
)
}The FilesystemIterator classIntroductionThe Filesystem iterator Class synopsisFilesystemIterator
class FilesystemIterator
extends
DirectoryIterator
implements
SeekableIterator
{
/* Constants */
const
integer
FilesystemIterator::CURRENT_AS_PATHNAME
= 32
;
const
integer
FilesystemIterator::CURRENT_AS_FILEINFO
= 0
;
const
integer
FilesystemIterator::CURRENT_AS_SELF
= 16
;
const
integer
FilesystemIterator::CURRENT_MODE_MASK
= 240
;
const
integer
FilesystemIterator::KEY_AS_PATHNAME
= 0
;
const
integer
FilesystemIterator::KEY_AS_FILENAME
= 256
;
const
integer
FilesystemIterator::FOLLOW_SYMLINKS
= 512
;
const
integer
FilesystemIterator::KEY_MODE_MASK
= 3840
;
const
integer
FilesystemIterator::NEW_CURRENT_AND_KEY
= 256
;
const
integer
FilesystemIterator::SKIP_DOTS
= 4096
;
const
integer
FilesystemIterator::UNIX_PATHS
= 8192
;
/* Methods */
public __construct
( string
$path
[, int $flags = FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::SKIP_DOTS
] )
public mixed current
( void
)
public int getFlags
( void
)
public string key
( void
)
public void next
( void
)
public void rewind
( void
)
public void setFlags
([ int
$flags
] )/* Inherited methods */
public DirectoryIterator DirectoryIterator::current
( void
)
public int DirectoryIterator::getATime
( void
)
public
string
DirectoryIterator::getBasename
([
string
$suffix
] )
public int DirectoryIterator::getCTime
( void
)
public string DirectoryIterator::getExtension
( void
)
public string DirectoryIterator::getFilename
( void
)
public int DirectoryIterator::getGroup
( void
)
public int DirectoryIterator::getInode
( void
)
public int DirectoryIterator::getMTime
( void
)
public int DirectoryIterator::getOwner
( void
)
public string DirectoryIterator::getPath
( void
)
public string DirectoryIterator::getPathname
( void
)
public int DirectoryIterator::getPerms
( void
)
public int DirectoryIterator::getSize
( void
)
public string DirectoryIterator::getType
( void
)
public bool DirectoryIterator::isDir
( void
)
public bool DirectoryIterator::isDot
( void
)
public bool DirectoryIterator::isExecutable
( void
)
public bool DirectoryIterator::isFile
( void
)
public bool DirectoryIterator::isLink
( void
)
public bool DirectoryIterator::isReadable
( void
)
public bool DirectoryIterator::isWritable
( void
)
public string DirectoryIterator::key
( void
)
public void DirectoryIterator::next
( void
)
public void DirectoryIterator::rewind
( void
)
public
void
DirectoryIterator::seek
( int
$position
)
public
string
DirectoryIterator::__toString
( void
)
public bool DirectoryIterator::valid
( void
)
}Predefined Constants
Changelog
The FilterIterator classIntroductionThis abstract iterator filters out unwanted values. This class should be extended to implement custom iterator filters. The FilterIterator::accept must be implemented in the subclass. Class synopsisFilterIterator
abstract
class FilterIterator
extends
IteratorIterator
implements
OuterIterator
{
/* Methods */
public
abstract
bool accept
( void
)
public
__construct
( Iterator
$iterator
)
public mixed current
( void
)
public Iterator getInnerIterator
( void
)
public mixed key
( void
)
public void next
( void
)
public void rewind
( void
)
public bool valid
( void
)
}The GlobIterator classIntroductionIterates through a file system in a similar fashion to glob. Class synopsisGlobIterator
class GlobIterator
extends
FilesystemIterator
implements
SeekableIterator
,
Countable
{
/* Methods */
public __construct
( string
$path
[, int $flags = FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO
] )
public int count
( void
)
/* Inherited methods */
public FilesystemIterator::__construct
( string
$path
[, int $flags = FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::SKIP_DOTS
] )
public mixed FilesystemIterator::current
( void
)
public int FilesystemIterator::getFlags
( void
)
public string FilesystemIterator::key
( void
)
public void FilesystemIterator::next
( void
)
public void FilesystemIterator::rewind
( void
)
public void FilesystemIterator::setFlags
([ int
}$flags
] )The InfiniteIterator classIntroductionThe InfiniteIterator allows one to infinitely iterate over an iterator without having to manually rewind the iterator upon reaching its end. Class synopsisInfiniteIterator
class InfiniteIterator
extends
IteratorIterator
implements
OuterIterator
{
/* Methods */
public __construct
( Iterator
$iterator
)
public void next
( void
)
/* Inherited methods */
public IteratorIterator::__construct
( Traversable
$iterator
)
public mixed IteratorIterator::current
( void
)
public Traversable IteratorIterator::getInnerIterator
( void
)
public scalar IteratorIterator::key
( void
)
public void IteratorIterator::next
( void
)
public void IteratorIterator::rewind
( void
)
public bool IteratorIterator::valid
( void
)
}The IteratorIterator classIntroductionThis iterator wrapper allows the conversion of anything that is Traversable into an Iterator. It is important to understand that most classes that do not implement Iterators have reasons as most likely they do not allow the full Iterator feature set. If so, techniques should be provided to prevent misuse, otherwise expect exceptions or fatal errors. Class synopsisIteratorIterator
class IteratorIterator
implements
OuterIterator
{
/* Methods */
public __construct
( Traversable
$iterator
)
public mixed current
( void
)
public Traversable getInnerIterator
( void
)
public scalar key
( void
)
public void next
( void
)
public void rewind
( void
)
public bool valid
( void
)
}The LimitIterator classIntroductionThe LimitIterator class allows iteration over a limited subset of items in an Iterator. Class synopsisLimitIterator
class LimitIterator
extends
IteratorIterator
implements
OuterIterator
{
/* Methods */
public __construct
( Iterator
$iterator
[, int $offset = 0
[, int $count = -1
]] )
public mixed current
( void
)
public Iterator getInnerIterator
( void
)
public int getPosition
( void
)
public mixed key
( void
)
public void next
( void
)
public void rewind
( void
)
public int seek
( int
$position
)
public bool valid
( void
)
}Examples
Example #1 LimitIterator usage example
<?php The above example will output: string(5) "apple" string(6) "banana" string(6) "cherry" string(6) "cherry" string(6) "damson" string(10) "elderberry" The MultipleIterator classIntroductionAn Iterator that sequentially iterates over all attached iterators Class synopsisMultipleIterator
class MultipleIterator
implements
Iterator
{
/* Constants */
const
integer
MultipleIterator::MIT_NEED_ANY
= 0
;
const
integer
MultipleIterator::MIT_NEED_ALL
= 1
;
const
integer
MultipleIterator::MIT_KEYS_NUMERIC
= 0
;
const
integer
MultipleIterator::MIT_KEYS_ASSOC
= 2
;
/* Methods */
public
__construct
([
int
$flags
= MultipleIterator::MIT_NEED_ALL|MultipleIterator::MIT_KEYS_NUMERIC
] )
public void attachIterator
( Iterator
$iterator
[, string $infos
] )
public void containsIterator
( Iterator
$iterator
)
public void countIterators
( void
)
public array current
( void
)
public void detachIterator
( Iterator
$iterator
)
public void getFlags
( void
)
public array key
( void
)
public void next
( void
)
public void rewind
( void
)
public void setFlags
( int
$flags
)
public void valid
( void
)
}Predefined Constants
The NoRewindIterator classIntroductionThis iterator cannot be rewound. Class synopsisNoRewindIterator
class NoRewindIterator
extends
IteratorIterator
{
/* Methods */
public __construct
( Iterator
$iterator
)
public mixed current
( void
)
public iterator getInnerIterator
( void
)
public mixed key
( void
)
public void next
( void
)
public void rewind
( void
)
public bool valid
( void
)
/* Inherited methods */
public IteratorIterator::__construct
( Traversable
$iterator
)
public mixed IteratorIterator::current
( void
)
public Traversable IteratorIterator::getInnerIterator
( void
)
public scalar IteratorIterator::key
( void
)
public void IteratorIterator::next
( void
)
public void IteratorIterator::rewind
( void
)
public bool IteratorIterator::valid
( void
)
}The ParentIterator classIntroductionThis extended FilterIterator allows a recursive iteration using RecursiveIteratorIterator that only shows those elements which have children. Class synopsisParentIterator
class ParentIterator
extends
RecursiveFilterIterator
implements
RecursiveIterator
,
OuterIterator
{
/* Methods */
public bool accept
( void
)
public __construct
( RecursiveIterator
$iterator
)
public ParentIterator getChildren
( void
)
public bool hasChildren
( void
)
public void next
( void
)
public void rewind
( void
)
}The RecursiveArrayIterator classIntroductionThis 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 synopsisRecursiveArrayIterator
class RecursiveArrayIterator
extends
ArrayIterator
implements
RecursiveIterator
{
/* 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
( string
$cmp_function
)
public void ArrayIterator::uksort
( string
$cmp_function
)
public string ArrayIterator::unserialize
( string
$serialized
)
public bool ArrayIterator::valid
( void
)
}The RecursiveCachingIterator classIntroduction... Class synopsisRecursiveCachingIterator
class RecursiveCachingIterator
extends
CachingIterator
implements
Countable
,
ArrayAccess
,
OuterIterator
,
RecursiveIterator
{
/* Methods */
public __construct
( Iterator
$iterator
[, string $flags = self::CALL_TOSTRING
] )
public RecursiveCachingIterator getChildren
( void
)
public bool hasChildren
( void
)
/* Inherits */
public CachingIterator::__construct
( Iterator
$iterator
[, string $flags = self::CALL_TOSTRING
] )
public int CachingIterator::count
( void
)
public void CachingIterator::current
( void
)
public void CachingIterator::getCache
( void
)
public void CachingIterator::getFlags
( void
)
public Iterator CachingIterator::getInnerIterator
( void
)
public void CachingIterator::hasNext
( void
)
public scalar CachingIterator::key
( void
)
public void CachingIterator::next
( void
)
public void CachingIterator::offsetExists
( string
$index
)
public void CachingIterator::offsetGet
( string
$index
)
public void CachingIterator::offsetSet
( string
$index
, string $newval
)
public void CachingIterator::offsetUnset
( string
$index
)
public void CachingIterator::rewind
( void
)
public void CachingIterator::setFlags
( bitmask
$flags
)
public void CachingIterator::__toString
( void
)
public void CachingIterator::valid
( void
)
}The RecursiveCallbackFilterIterator classIntroduction
Class synopsisRecursiveCallbackFilterIterator
class RecursiveCallbackFilterIterator
extends
CallbackFilterIterator
implements
OuterIterator
,
RecursiveIterator
{
/* Methods */
public
__construct
( RecursiveIterator
$iterator
, string $callback
)
public RecursiveCallbackFilterIterator getChildren
( void
)
public void hasChildren
( void
)
/* Inherited methods */
public string CallbackFilterIterator::accept
( void
)
}ExamplesThe callback should accept up to three arguments: the current item, the current key and the iterator, respectively. Example #1 Available callback arguments
<?php
Filtering a recursive iterator generally involves two conditions.
The first is that, to allow recursion, the callback function should return Example #2 Recursive callback basic example
<?php The RecursiveDirectoryIterator classIntroductionThe RecursiveDirectoryIterator provides an interface for iterating recursively over filesystem directories. Class synopsisRecursiveDirectoryIterator
class RecursiveDirectoryIterator
extends
FilesystemIterator
implements
SeekableIterator
,
RecursiveIterator
{
/* Methods */
public __construct
( string
$path
[, int $flags = FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO
] )
public mixed getChildren
( void
)
public string getSubPath
( void
)
public string getSubPathname
( void
)
public bool hasChildren
([ bool
$allow_links = false
] )
public string key
( void
)
public void next
( void
)
public void rewind
( void
)
/* Inherits */
public FilesystemIterator::__construct
( string
$path
[, int $flags = FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::SKIP_DOTS
] )
public mixed FilesystemIterator::current
( void
)
public int FilesystemIterator::getFlags
( void
)
public string FilesystemIterator::key
( void
)
public void FilesystemIterator::next
( void
)
public void FilesystemIterator::rewind
( void
)
public void FilesystemIterator::setFlags
([ int
}$flags
] )Changelog
The RecursiveFilterIterator classIntroductionThis abstract iterator filters out unwanted values for a RecursiveIterator. This class should be extended to implement custom filters. The RecursiveFilterIterator::accept must be implemented in the subclass. Class synopsisRecursiveFilterIterator
abstract
class RecursiveFilterIterator
extends
FilterIterator
implements
OuterIterator
,
RecursiveIterator
{
/* Methods */
public __construct
( RecursiveIterator
$iterator
)
public void getChildren
( void
)
public void hasChildren
( void
)
/* Inherited methods */
public
abstract
bool FilterIterator::accept
( void
)
public
FilterIterator::__construct
( Iterator
$iterator
)
public mixed FilterIterator::current
( void
)
public Iterator FilterIterator::getInnerIterator
( void
)
public mixed FilterIterator::key
( void
)
public void FilterIterator::next
( void
)
public void FilterIterator::rewind
( void
)
public bool FilterIterator::valid
( void
)
}The RecursiveIteratorIterator classIntroductionCan be used to iterate through recursive iterators. Class synopsisRecursiveIteratorIterator
class RecursiveIteratorIterator
implements
OuterIterator
{
/* Constants */
const
integer
RecursiveIteratorIterator::LEAVES_ONLY
= 0
;
const
integer
RecursiveIteratorIterator::SELF_FIRST
= 1
;
const
integer
RecursiveIteratorIterator::CHILD_FIRST
= 2
;
const
integer
RecursiveIteratorIterator::CATCH_GET_CHILD
= 16
;
/* Methods */
public void beginChildren
( void
)
public void beginIteration
( void
)
public RecursiveIterator callGetChildren
( void
)
public bool callHasChildren
( void
)
public __construct
( Traversable
$iterator
[, int $mode = RecursiveIteratorIterator::LEAVES_ONLY
[, int $flags = 0
]] )
public mixed current
( void
)
public void endChildren
( void
)
public void endIteration
( void
)
public int getDepth
( void
)
public iterator getInnerIterator
( void
)
public mixed getMaxDepth
( void
)
public RecursiveIterator getSubIterator
([ int
$level
] )
public mixed key
( void
)
public void next
( void
)
public void nextElement
( void
)
public void rewind
( void
)
public void setMaxDepth
([ string
$max_depth = -1
] )
public bool valid
( void
)
/* Inherited methods */
public Iterator OuterIterator::getInnerIterator
( void
)
}Predefined Constants
The RecursiveRegexIterator classIntroductionThis recursive iterator can filter another recursive iterator via a regular expression. Class synopsisRecursiveRegexIterator
class RecursiveRegexIterator
extends
RegexIterator
implements
RecursiveIterator
{
/* Methods */
public __construct
( RecursiveIterator
$iterator
, string $regex
[, int $mode = self::MATCH
[, int $flags = 0
[, int $preg_flags = 0
]]] )
public RecursiveRegexIterator getChildren
( void
)
public bool hasChildren
( void
)
/* Inherited methods */
public RecursiveIterator RecursiveIterator::getChildren
( void
)
public bool RecursiveIterator::hasChildren
( void
)
public bool RegexIterator::accept
( void
)
public int RegexIterator::getFlags
( void
)
public int RegexIterator::getMode
( void
)
public int RegexIterator::getPregFlags
( void
)
public string RegexIterator::getRegex
( void
)
public void RegexIterator::setFlags
( int
$flags
)
public void RegexIterator::setMode
( int
$mode
)
public void RegexIterator::setPregFlags
( int
}$preg_flags
)The RecursiveTreeIterator classIntroductionAllows iterating over a RecursiveIterator to generate an ASCII graphic tree. Class synopsisRecursiveTreeIterator
class RecursiveTreeIterator
extends
RecursiveIteratorIterator
implements
OuterIterator
{
/* Constants */
const
integer
RecursiveTreeIterator::BYPASS_CURRENT
= 4
;
const
integer
RecursiveTreeIterator::BYPASS_KEY
= 8
;
const
integer
RecursiveTreeIterator::PREFIX_LEFT
= 0
;
const
integer
RecursiveTreeIterator::PREFIX_MID_HAS_NEXT
= 1
;
const
integer
RecursiveTreeIterator::PREFIX_MID_LAST
= 2
;
const
integer
RecursiveTreeIterator::PREFIX_END_HAS_NEXT
= 3
;
const
integer
RecursiveTreeIterator::PREFIX_END_LAST
= 4
;
const
integer
RecursiveTreeIterator::PREFIX_RIGHT
= 5
;
/* Methods */
public void beginChildren
( void
)
public RecursiveIterator beginIteration
( void
)
public RecursiveIterator callGetChildren
( void
)
public bool callHasChildren
( void
)
public __construct
( RecursiveIterator|IteratorAggregate
$it
[, int $flags = RecursiveTreeIterator::BYPASS_KEY
[, int $cit_flags = CachingIterator::CATCH_GET_CHILD
[, int $mode = RecursiveIteratorIterator::SELF_FIRST
]]] )
public string current
( void
)
public void endChildren
( void
)
public void endIteration
( void
)
public string getEntry
( void
)
public void getPostfix
( void
)
public string getPrefix
( void
)
public string key
( void
)
public void next
( void
)
public void nextElement
( void
)
public void rewind
( void
)
public void setPrefixPart
( int
$part
, string $value
)
public bool valid
( void
)
/* Inherited methods */
public void RecursiveIteratorIterator::beginChildren
( void
)
public void RecursiveIteratorIterator::beginIteration
( void
)
public RecursiveIterator RecursiveIteratorIterator::callGetChildren
( void
)
public bool RecursiveIteratorIterator::callHasChildren
( void
)
public RecursiveIteratorIterator::__construct
( Traversable
$iterator
[, int $mode = RecursiveIteratorIterator::LEAVES_ONLY
[, int $flags = 0
]] )
public mixed RecursiveIteratorIterator::current
( void
)
public void RecursiveIteratorIterator::endChildren
( void
)
public void RecursiveIteratorIterator::endIteration
( void
)
public int RecursiveIteratorIterator::getDepth
( void
)
public iterator RecursiveIteratorIterator::getInnerIterator
( void
)
public mixed RecursiveIteratorIterator::getMaxDepth
( void
)
public RecursiveIterator RecursiveIteratorIterator::getSubIterator
([ int
$level
] )
public mixed RecursiveIteratorIterator::key
( void
)
public void RecursiveIteratorIterator::next
( void
)
public void RecursiveIteratorIterator::nextElement
( void
)
public void RecursiveIteratorIterator::rewind
( void
)
public void RecursiveIteratorIterator::setMaxDepth
([ string
$max_depth = -1
] )
public bool RecursiveIteratorIterator::valid
( void
)
}Predefined Constants
The RegexIterator classIntroductionThis iterator can be used to filter another iterator based on a regular expression. Class synopsisRegexIterator
class RegexIterator
extends
FilterIterator
{
/* Constants */
const
integer
MATCH
= 0
;
const
integer
GET_MATCH
= 1
;
const
integer
ALL_MATCHES
= 2
;
const
integer
SPLIT
= 3
;
const
integer
REPLACE
= 4
;
const
integer
USE_KEY
= 1
;
/* Methods */
public __construct
( Iterator
$iterator
, string $regex
[, int $mode = self::MATCH
[, int $flags = 0
[, int $preg_flags = 0
]]] )
public bool accept
( void
)
public int getFlags
( void
)
public int getMode
( void
)
public int getPregFlags
( void
)
public string getRegex
( void
)
public void setFlags
( int
$flags
)
public void setMode
( int
$mode
)
public void setPregFlags
( int
$preg_flags
)/* Inherited methods */
public
abstract
bool FilterIterator::accept
( void
)
public
FilterIterator::__construct
( Iterator
$iterator
)
public mixed FilterIterator::current
( void
)
public Iterator FilterIterator::getInnerIterator
( void
)
public mixed FilterIterator::key
( void
)
public void FilterIterator::next
( void
)
public void FilterIterator::rewind
( void
)
public bool FilterIterator::valid
( void
)
}Predefined ConstantsRegexIterator operation modes
RegexIterator Flags
|