object to array


/ Published in: PHP
Save to your folder(s)

coolstuff.


Copy this code and paste it in your HTML
  1. function objectToArray($object, $includes = array()){
  2. $retArray = array();
  3. $i = 0;
  4. foreach($object->all as $o){
  5. $retArray[$i] = $o->_to_array();
  6. if(count($includes) > 0){
  7. foreach($includes as $include){
  8. foreach($o->{$include}->get()->all as $inc){
  9. $retArray[$i][$include][] = $inc->_to_array();
  10. }
  11. }
  12. }
  13. ++$i;
  14. }
  15.  
  16. return $retArray;
  17. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.