What you have there works fine, is simple, and is relatively quick so I'm not sure why you're looking for something built-in.
That being said, an alternative is to make a class that simply copies the array to a private variable, and uses the magic __get and __set functions for access outside of the class. Perhaps something like this might help if you want to go in that direction: http://us2.php.net/manual/en/language.oop5.overloading.php#language.oop5 .overloading.members Mike Tramontano eFashion Solutions - Sr Backend Developer [email protected] From: [email protected] [mailto:[email protected]] On Behalf Of A.J. Brown Sent: Friday, February 06, 2009 12:24 PM To: Zend Framework General Subject: [fw-general] stdClass Question Hey guys, This is probably more approriate for the PHP list, but I'm not subscribed with this email address, so I'll pose it here. Is there a better / built in way to turn an array into a stdClass? //TODO (is there / why isn't there) a built in way to do this? $oTrack = new stdClass(); foreach( $trackData as $key => $value ) { $oTrack->$key = $value; } I'm doing this because the user has the option of passing in either a model (an object type), or an array of the data that would be in the model. But, I don't want to have two different code paths for processing the data. -- A.J. Brown web | http://ajbrown.org phone | (937) 660-3969
