Created
June 1, 2010 12:53
-
-
Save assertchris/420913 to your computer and use it in GitHub Desktop.
PHP object->array method
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
function toArray($result) | |
{ | |
$array = array(); | |
foreach ($result as $key => $value) | |
{ | |
if (is_object($value)) | |
{ | |
$array[$key] = toArray($value); | |
} | |
else if (is_array($value)) | |
{ | |
$array[$key] = toArray($value); | |
} | |
else | |
{ | |
$array[$key] = $value; | |
} | |
} | |
return $array; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment