I'm trying to access array keys via object notation. I thought code below should work?
<?php
$accountData = array('role'=> 'user');
$accountDataAO = new ArrayObject($accountData, ArrayObject::STD_PROP_LIST);
echo $accountDataAO->role;
?>
But I get this:
PHP Notice: Undefined property: ArrayObject::$role in /home/stan/Desktop/test.php on line 5
PHP Stack trace:
PHP 1. {main}() /home/stan/Desktop/test.php:0
What am I doing wrong?
This class allows objects to work as arrays.==> not arrays as objects. Eitherway, check the manual php.net/manual/en/class.arrayobject.phpArrayObject::setFlags()manual page.