Posted By

madmike on 07/05/09


Tagged


Versions (?)

object to array


 / Published in: PHP
 

coolstuff.

  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  

You need to login to post a comment.