accessing an object like an array

    Date: 02/20/09 (PHP Development)    Keywords: no keywords

    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.

    
    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.

    Source: http://community.livejournal.com/php_dev/81372.html

« php driven image gallery -... || Writing a SOAP server »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home