PHP  
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: Mon, 16 Jul 2012

ArrayObject::getIterator

(no version information, might be only in CVS)

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

Description

ArrayIterator ArrayObject::getIterator ( void )

This function will return an iterator from an ArrayObject.

例子 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




<ArrayObject::countArrayObject::offsetExists>
 Last updated: Mon, 16 Jul 2012
 
Copyright © 2001-2005 The PHP Group
All rights reserved.
This unofficial mirror is operated at: http://manual.phpv.net/
Last updated: Thu Jul 7 19:13:47 2005 CST