Arrayaccess Interface
The Arrayaccess interface is an object that behaves like a set of arrays, and defines four methods. The interface is summarized as follows:
arrayaccess {/**/abstract public boolean offsetexists ( Mixed $offset)abstract public mixed offsetget (mixed $offset)abstract Public void offsetset (mixed $offset, mixed $value) Abstract Public void offsetunset (mixed $offset)}
The Arrayaccess interface itself does not provide a function of calculating the number of heavy elements in the book group, if the number to be calculated can be achieved by implementing the Countble interface. This interface contains a count () method, and returns the number of elements.
PhpclassMyArray implements arrayaccess{protected$_arr; Publicfunction __construct () {$ This->_arr =Array (); } Publicfunction Offsetset ($offset, $value) {$ This->_arr[$offset] =$value; } Publicfunction Offsetget ($offset) {return$ This-_arr[$offset]; } Publicfunction Offsetexists ($offset) {returnArray_key_exists ($offset, $ This-_arr); } Publicfunction Offsetunset ($offset) {unset ($ This-_arr[$offset]); }} $MyArray=NewMyArray (); $MyArray [' First'] ='Test'; Echo $MyArray [' First'];unset ($MyArray [' First']);?>
Arratobject Class Introduction
The Arrayobject class is an implementation class for an Arrayaccess interface that provides iterative functionality and a number of very useful ways to sort and manipulate data.
ArrayobjectImplementsIteratoraggregate, Arrayaccess, Serializable,countable {/*Constants*/Const integerStd_prop_list = 1 ;Const integerArray_as_props = 2 ;/*Methods*/ Public__construct ([Mixed $input= [] [, int$flags= 0 [,string $iterator _class= "Arrayiterator" ]]] ) Publicvoid Append (Mixed $value ) PublicvoidAsort(void) PublicIntCount(void) Public ArrayExchangearray (Mixed $input ) Public Arraygetarraycopy (void) Publicint getflags (void) Publicarrayiterator getiterator (void) Public stringgetiteratorclass (void) PublicvoidKsort(void) PublicvoidNatcasesort(void) PublicvoidNatsort(void) PublicBOOL Offsetexists (Mixed $index ) Public MixedOffsetget (Mixed $index ) Publicvoid Offsetset (Mixed $index,Mixed $newval ) Publicvoid Offsetunset (Mixed $index ) Public string Serialize(void) Publicvoid SetFlags (int$flags ) Publicvoid Setiteratorclass (string $iterator _class ) PublicvoidUasort(Callable$cmp _function ) PublicvoidUksort(Callable$cmp _function ) Publicvoidunserialize(string $serialized )}
http://www.bkjia.com/PHPjc/815979.html www.bkjia.com true http://www.bkjia.com/PHPjc/815979.html techarticle The arrayaccess interface Arrayaccess interface is an object that behaves like a set of arrays, and defines four methods. The interface is summarized as follows: arrayaccess {/* Methods */Abstract public boolean OFFSE ...