Created
November 19, 2013 19:11
-
-
Save felipevolpatto/7550771 to your computer and use it in GitHub Desktop.
PHP Object Helper.
toArray() -> Object to array implementation.
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 | |
class ObjectHelper { | |
private function __construct() { } | |
public static function toArray($obj) { | |
if (is_object($obj)) { | |
$obj = get_object_vars($obj); | |
} | |
return (is_array($obj)) | |
? array_map(array(__CLASS__, __FUNCTION__), $obj) | |
: $obj; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment