Man In Tan Posted August 17, 2011 Share Posted August 17, 2011 I need to typecast an array as an object, so I can use methods the deal with the former array's data. However, direct typecasting results in an instance of the stdClass class, which is not even remotely helpful with custom methods. Currently, I'm using a foreach statement to handle the conversion process, as shown below, but from what I've read, this is a slow way to handle these kinds of data processing. Is there a more efficient way? <?php foreach($array as $key => $value){ $object->$key = $value; } Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.