Where can I find the ArrayObject’s complete source code (in PHP)?
What I dont understand is why you can use the “arrow” when add an element to your ArrayObject, for example:
$a = new ArrayObject();
$a['arr'] = 'array data';
$a->prop = 'prop data'; //here it is
You can see $a->prop = 'prop data'; is used.
Is there any magic method or what was used, and how PHP knows for example that $a['prop'] and $a->prop means the same ? (in this context)
Yes, it is magic and it can be accomplished directly in PHP. Take look at Overloading http://www.php.net/manual/en/language.oop5.overloading.php
You can use
__get()and__setin a class to do this. To make objects behave like arrays, you have to implement http://www.php.net/manual/en/class.arrayaccess.phpThis is my example code:
Instead of
current($a),next($a)use$a->current(),$a->next()