Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

regexiterator(3) [php man page]

REGEXITERATOR(3)							 1							  REGEXITERATOR(3)

The RegexIterator class

INTRODUCTION
This iterator can be used to filter another iterator based on a regular expression. CLASS SYNOPSIS
RegexIterator RegexIteratorextends FilterIterator Constants o const integer$MATCH0 o const integer$GET_MATCH1 o const integer$ALL_MATCHES2 o const integer$SPLIT3 o const integer$REPLACE4 o const integer$USE_KEY1 Methods o public RegexIterator::__construct (Iterator $iterator, string $regex, [int $mode = self::MATCH], [int $flags], [int $preg_flags]) o public bool RegexIterator::accept (void ) o public int RegexIterator::getFlags (void ) o public int RegexIterator::getMode (void ) o public int RegexIterator::getPregFlags (void ) o public string RegexIterator::getRegex (void ) o public void RegexIterator::setFlags (int $flags) o public void RegexIterator::setMode (int $mode) o public void RegexIterator::setPregFlags (int $preg_flags) Inherited methods o publicabstract bool FilterIterator::accept (void ) o public FilterIterator::__construct (Iterator $iterator) o public mixed FilterIterator::current (void ) o public Iterator FilterIterator::getInnerIterator (void ) o public mixed FilterIterator::key (void ) o public void FilterIterator::next (void ) o public void FilterIterator::rewind (void ) o public bool FilterIterator::valid (void ) PREDEFINED CONSTANTS
REGEXITERATOR OPERATION MODES
o RegexIterator::ALL_MATCHES - Return all matches for the current entry (see preg_match_all(3)). o RegexIterator::GET_MATCH - Return the first match for the current entry (see preg_match(3)). o RegexIterator::MATCH - Only execute match (filter) for the current entry (see preg_match(3)). o RegexIterator::REPLACE - Replace the current entry (see preg_replace(3); Not fully implemented yet) o RegexIterator::SPLIT - Returns the split values for the current entry (see preg_split(3)). REGEXITERATOR FLAGS
o RegexIterator::USE_KEY - Special flag: Match the entry key instead of the entry value. PHP Documentation Group REGEXITERATOR(3)

Check Out this Related Man Page

CALLBACKFILTERITERATOR(3)						 1						 CALLBACKFILTERITERATOR(3)

The CallbackFilterIterator class

INTRODUCTION
CLASS SYNOPSIS
CallbackFilterIterator CallbackFilterIteratorextends FilterIteratorOuterIterator Methods o public CallbackFilterIterator::__construct (Iterator $iterator, callable $callback) o public string CallbackFilterIterator::accept (void ) Inherited methods o publicabstract bool FilterIterator::accept (void ) o public FilterIterator::__construct (Iterator $iterator) o public mixed FilterIterator::current (void ) o public Iterator FilterIterator::getInnerIterator (void ) o public mixed FilterIterator::key (void ) o public void FilterIterator::next (void ) o public void FilterIterator::rewind (void ) o public bool FilterIterator::valid (void ) EXAMPLES
The callback should accept up to three arguments: the current item, the current key and the iterator, respectively. Example #1 Available callback arguments <?php /** * Callback for CallbackFilterIterator * * @param $current Current item's value * @param $key Current item's key * @param $iterator Iterator being filtered * @return boolean TRUE to accept the current item, FALSE otherwise */ function my_callback($current, $key, $iterator) { // Your filtering code here } ?> 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 $dir = new FilesystemIterator(__DIR__); // Filter large files ( > 100MB) function is_large_file($current) { return $current->isFile() && $current->getSize() > 104857600; } $large_files = new CallbackFilterIterator($dir, 'is_large_file'); // Filter directories $files = new CallbackFilterIterator($dir, function ($current, $key, $iterator) { return $current->isDir() && ! $iterator->isDot(); }); ?> PHP Documentation Group CALLBACKFILTERITERATOR(3)
Man Page