Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. function indenter($locations, $parent_id = null, $prefix = '') {
  2. $results = Array();
  3. foreach($locations as $location) {
  4. if($location->parent_id == $parent_id) {
  5. //append this parent node first,
  6. $location->use_text = $prefix.' '.$location->name
  7. $results[] = $location;
  8. //now append the children.
  9. $results = array_merge($results,indenter($locations,$location->id,$prefix.'--'));
  10. }
  11. }
  12. return $results;
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement