Guest User

Untitled

a guest
Oct 16th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. function objectToArray($d) {
  2. if (is_object($d)) {
  3. // Gets the properties of the given object
  4. // with get_object_vars function
  5. $d = get_object_vars($d);
  6. }
  7.  
  8. if (is_array($d)) {
  9. /*
  10. * Return array converted to object
  11. * Using __FUNCTION__ (Magic constant)
  12. * for recursive call
  13. */
  14. return array_map(__FUNCTION__, $d);
  15. }
  16. else {
  17. // Return array
  18. return $d;
  19. }
  20. } // objectToArray()
Add Comment
Please, Sign In to add comment