Created
March 30, 2015 15:04
-
-
Save xus/beee57bdbfffab34a9b7 to your computer and use it in GitHub Desktop.
Objects to array ( Perfect to consume SOAP )
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
function obj2array($obj) { | |
$out = array(); | |
foreach ($obj as $key => $val) { | |
switch(true) { | |
case is_object($val): | |
$out[$key] = obj2array($val); | |
break; | |
case is_array($val): | |
$out[$key] = obj2array($val); | |
break; | |
default: | |
$out[$key] = $val; | |
} | |
} | |
return $out; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment