PHP retrieving array values using dash arrow "->"
The variables that allow you get properties with ->
are actually objects, not arrays. They do allow the ['some_key']
syntax, but that doesn't mean they are arrays. They are not.
You can reading more about objects on this page of the PHP manual.
As stated before in other answers, using ->
means you are accessing an object, not an array.
However, it is sometimes possible that an object would be treated as an array. It is when it is implementing ArrayAccess
interface. The coder can do such that eg. calling $object->field
would be equivalent to $object['field']
, but he/she must not.
Moreover, it is possible to treat an array as an object (refer to the manual), however in this case it is not an array but an object and is the same way as above.