ArrayObject::getIterator

(PHP 5, PHP 7)

ArrayObject::getIteratorCreate a new iterator from an ArrayObject instance

说锟斤拷

public ArrayObject::getIterator ( void ) : ArrayIterator

Create a new iterator from an ArrayObject instance.

锟斤拷锟斤拷

锟剿猴拷锟斤拷没锟叫诧拷锟斤拷锟斤拷

锟斤拷锟斤拷值

An iterator from an ArrayObject.

锟斤拷锟斤拷

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();
}
?>

锟斤拷锟斤拷锟斤拷锟教伙拷锟斤拷锟斤拷锟�

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