Last active
October 26, 2016 09:03
-
-
Save berliozd/9094858a3489eced922c636b76d0172b to your computer and use it in GitHub Desktop.
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 | |
/** | |
* Transform multi dimension object in multi dimension array | |
* | |
* @param $obj | |
* @return array | |
*/ | |
private static function toArray($obj) | |
{ | |
if (is_object($obj)) { | |
$obj = (array)$obj; | |
} | |
if (is_array($obj)) { | |
$new = array(); | |
foreach ($obj as $key => $val) { | |
$new[$key] = self::toArray($val); | |
} | |
} else { | |
$new = $obj; | |
} | |
return $new; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment