Re: [nyphp-talk] passing array/object data

2008-11-24 Thread anoland
ate: Monday, Nov 24, 2008 2:14 pm Subject: [nyphp-talk] passing array/object data To: talk - nyphp Reply-To: NYPHP Talk I have a method that takes a parameter that might be either an array or >a db result object. So on the one hand I might have: >echo $array['stuff']; >or o

Re: [nyphp-talk] passing array/object data

2008-11-24 Thread Elijah Insua
echo (object)$data->something or even better, wrap the whole thing in a 'result object'.. class resultObject { protected $data = array(); public function __construct($data) { $this->data = (array)$data; } public function __get($k) { return (isset($this->data[$k])) ? $this->data[$k] : n

[nyphp-talk] passing array/object data

2008-11-24 Thread Michael Southwell
I have a method that takes a parameter that might be either an array or a db result object. So on the one hand I might have: echo $array['stuff']; or on the other: echo $result -> stuff; Right now I'm just using is_array and repeated brute force to do this, but obviously there's a better way. W