Skip to content

Instantly share code, notes, and snippets.

@xus
Created March 30, 2015 15:04
Show Gist options
  • Save xus/beee57bdbfffab34a9b7 to your computer and use it in GitHub Desktop.
Save xus/beee57bdbfffab34a9b7 to your computer and use it in GitHub Desktop.
Objects to array ( Perfect to consume SOAP )
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