[nycphp-talk] passing array/object data

anoland at anoland at
Mon Nov 24 14:47:35 EST 2008

Use SPL to implement ArrayAccess on your db object? Then you can use one check and not resort to brute forcing all the others.
it would turn into:
echo $result['stuff'];

Dunno if that is completely clear.

-----Original Message-----
From: Michael Southwell <michael.southwell at>
Date: Monday, Nov 24, 2008 2:14 pm
Subject: [nycphp-talk] passing array/object data
To: talk - nyphp <talk at>Reply-To: NYPHP Talk <talk at>

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. What's my best way to abstract this 
>so I can use just one echo statement regardless of the parameter?
>Michael Southwell
>Vice President, Education
>New York PHP User Group Community Talk Mailing List

More information about the talk mailing list