dismiss Step into the future! Click here to switch to the beta php.net site
downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

CachingIterator::__construct> <ArrayIterator::valid
[edit] Last updated: Fri, 04 Oct 2013

view this page in

The CachingIterator class

(PHP 5)

Introduction

This object supports cached iteration over another iterator.

Class synopsis

CachingIterator extends IteratorIterator implements OuterIterator , ArrayAccess , Countable {
/* Constants */
const integer CALL_TOSTRING = 1 ;
const integer CATCH_GET_CHILD = 16 ;
const integer TOSTRING_USE_KEY = 2 ;
const integer TOSTRING_USE_CURRENT = 4 ;
const integer TOSTRING_USE_INNER = 8 ;
const integer 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

CachingIterator::CALL_TOSTRING

Convert every element to string.

CachingIterator::CATCH_GET_CHILD

Don't throw exception in accessing children.

CachingIterator::TOSTRING_USE_KEY

Use key for conversion to string.

CachingIterator::TOSTRING_USE_CURRENT

Use current for conversion to string.

CachingIterator::TOSTRING_USE_INNER

Use inner for conversion to string.

CachingIterator::FULL_CACHE

Cache all read data.

Table of Contents



add a note add a note User Contributed Notes CachingIterator - [1 notes]
up
-1
seyferseed at mail dot ru
2 months ago
With this helpful iterator you can use hasNext() method, becouse inline iterator cached

<?php
$names
= array("Jessey", "Joe","Jane");
$inames = new ArrayIterator($names);

$ci = new CachingIterator($inames);

foreach (
$ci as $item)
{

  echo
$item;

  if (
$item->hasNext())
    echo
" , ";

}

//output
//Jessey, Joe, Jane
?>

 
show source | credits | sitemap | contact | advertising | mirror sites