downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
search for in the  

<ArrayObject::countArrayObject::offsetExists>
Last updated: Thu, 26 Jun 2008

ArrayObject::getIterator

(PHP 5)

ArrayObject::getIterator — Create a new iterator from an ArrayObject instance

Description

ArrayIterator ArrayObject::getIterator ( void )

Create a new iterator from an ArrayObject instance.

Parameters

This function has no parameters.

Return Values

An iterator from an ArrayObject.

Examples

Example #1 ArrayObject::getIterator() example

<?php
$array
= array('1' => 'one',
              
'2' => 'two',
              
'3' => 'three');

$arrayobject = new ArrayObject($array);

$iterator = $arrayobject->getIterator();

while(
$iterator->valid()) {
   echo
$iterator->key() . ' => ' . $iterator->current() . "\n";

  
$iterator->next();
}
?>

The above example will output:

1 => one
2 => two
3 => three



add a noteadd a note User Contributed Notes
Create a new iterator from an ArrayObject instance
There are no user contributed notes for this page.




<ArrayObject::countArrayObject::offsetExists>
Last updated: Thu, 26 Jun 2008
show source | credits | sitemap | contact | advertising | mirror sites
Copyright © 2001-2005 The PHP Group
All rights reserved.
This unofficial mirror is operated at: http://phpbuilder.com/
Last updated: Tue Nov 1 20:20:59 2005 EST
Columns / Articles | Tips / Quickies | News | News Linking and RSS Feeds | Shared Code Library
Mail Archives | Support / Discussion Forums | Get Started! Links | Contribute! | Docs