accessing an object like an array
I am hoping someone can point me in the right direction.
I have an object that at some point sets one of it's variables as an array.
I know it can be done, I just don't know the specifics, and I think it has something to do with Obect Iteration, but the docs are confusing me. Thanks.
I have an object that at some point sets one of it's variables as an array.
class myClass
{
private $data = array()
public function __construct($newData=array())
{
$this->setData($newData);
}
public function getData()
{
return $this->data;
}
public function setData($newData=array())
{
$this->data = $newData;
}
}
$dataObj = new myClass($someDataArray);
// I want to be able to do.
print $dataObh['myArrayKey']
// and get back the data that that key holds in the object $data variable
I know it can be done, I just don't know the specifics, and I think it has something to do with Obect Iteration, but the docs are confusing me. Thanks.
