arrays - Benefits of ArrayAccess Interface in PHP? -


implementing arrayaccess interface in php , can access object properties array keys . benefits of having object behave array?

like see frameworks implementing 'form' arrayaccess interface , can access (html) form objects fields like,

$form['namefield']   instead-of  $form->namefield  $form['titlefield']  instead-of  $form->titlefield 

whats benefit of using $form['namefield] instead-of $form->namefield

is speed of 'array data structures' or portability between object , array forms ?

or missing something? :)

there no functional benefit, structural.

if define map, suggest, can contain arbitrary number of named elements, of similar kinds. object properties defined , of different types.

in short: if implement arrayaccess "my object (also) behaves array".

http://en.wikipedia.org/wiki/associative_array


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -