Created
December 16, 2009 04:57
-
-
Save jaywilliams/257606 to your computer and use it in GitHub Desktop.
Convert a multi-dimensional array into a stdClass object. Pass by reference.
This file contains hidden or 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 array_to_object($array) | |
{ | |
return is_array($array) ? (object) array_map(__FUNCTION__,$array) : $array; | |
} | |
?> |
or simillary METHOD inside a class :]
thanks for that jay :\
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
very nice function
gj