Created
          September 10, 2013 14:29 
        
      - 
      
- 
        Save taion809/6510212 to your computer and use it in GitHub Desktop. 
    PHP Nested set to multidimensional array
  
        
  
    
      This file contains hidden or 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
    
  
  
    
  | private function _formatTreeIntoArray(&$tree, $current_depth = 0) | |
| { | |
| $formattedTree = array(); | |
| while($leaf = current($tree)) | |
| { | |
| if($leaf->DEPTH > $current_depth) | |
| { | |
| $formattedTree[] = $this->_formatTreeIntoArray($tree, $leaf->DEPTH); | |
| } | |
| elseif($leaf->DEPTH < $current_depth) | |
| { | |
| return $formattedTree; | |
| } | |
| else | |
| { | |
| $formattedTree[] = $leaf; | |
| next($tree); | |
| } | |
| } | |
| return $formattedTree; | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment