Arrayobject is to convert an array of arrays of objects, this article mainly to share with you arrayobject instructions, I hope to help everyone.
code example
<?php //Print all array elements $array =array (' 1 ' = ' one ', ' 2 ' + ', ' 3 ' = ' three ');
$arrayobject = new Arrayobject ($array);//Constructs a Arrayobject object for ($iterator = $arrayobject->getiterator ();
Constructs an iterator $iterator->valid ();//Checks if there are elements $iterator->next ()) {//points to the next element
echo $iterator->key (). ' = '. $iterator->current (). "\ n";//print array element}?><?php
Resets the array pointer $arrayobject =new arrayobject (); $arrayobject [] = ' zero ';
$arrayobject [] = ' one '; $arrayobject [] = ' one '; $iterator = $arrayobject->getiterator ();
Reset the pointer to the head echo $iterator->key (); 0?>
Common functions of Arrayobject
arrayiterator::current (void)
// Returns the current array element arrayiterator::key (void)
//Returns the current array keyarrayiterator::next (void)
//points to the next group element Arrayiterator::rewind ( void)
//reset array pointer to head arrayiterator::seek ()
//Find a location in the array arrayiterator::valid ()
//Check whether the array also contains other elements Arrayobject:: Append ()
//Add new Element Arrayobject::__construct ()
//construct a new Array object Arrayobject::count ()
//Return the number of elements in the iterator Arrayobject:: Getiterator ()
//Constructs a new iterator from an array object Arrayobject::offsetexists (mixed index)
//Determines whether the committed value exists Arrayobject::offsetget (
//Specify name to get the value Arrayobject::offsetset ()
//Modify the value of the specified name Arrayobject::offsetunset ()
//delete data