<?php /** * Convert an stdClass object to an array * * @param stdClass object $varObj The object to convert * @reeturn array * */ function convertObjectToArray($varObj) { if (!is_object($varObj) && !is_array($varObj)) { return $object; } if (is_object($varObj)) { $varObj = get_object_vars($varObj); } return array_map('objectToArray', $varObj); } /** convert the object to array **/ $resultArray = convertObjectToArray( $obj ); /** Display the result array **/ print_r( $resultArray ); ?>
Thursday, July 4, 2013
convert stdClass Object to Array in php
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment