-
-
Save chucktrukk/594195 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Convert a multi-dimensional array into a stdClass object. | |
* | |
* Example: | |
* $values = array('hello'=>'world'); | |
* | |
* // Convert the array to an object | |
* array_to_object($values); | |
* | |
* echo $values->hello; | |
* | |
* @param array $array The input array | |
* @return object | |
*/ | |
function array2obj($array) | |
{ | |
return is_array($array) ? (object) array_map(__FUNCTION__,$array) : $array; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment