Last active
April 8, 2017 08:39
-
-
Save dusta/1b070dc17ff2f163eb734b1dbdbfe6d3 to your computer and use it in GitHub Desktop.
Function Convert object to array
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 object to array | |
*/ | |
function objectToArray($obj) { | |
if(is_object($obj)) | |
$obj = (array) $obj; | |
if(is_array($obj)) { | |
$new = array(); | |
foreach($obj as $key => $val) { | |
$key2 = str_replace("\0", "", $key); | |
$new[$key2] = object_to_array($val); | |
} | |
}else | |
$new = $obj; | |
return $new; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment