PHP Return array from recursive function -


when echo out $value['id']. $value['label']; every row echoed out //that's want. but, when return $result first array returned.. how can fix this?

here's code:

    public function recursive_category($tree,$indent=0) {     $indent++; // try depth of current array     foreach ($tree $value) {         foreach ($value $key => $value) {             $indent_str = str_repeat("--", $indent);             echo $value['id'].' '.$value['label'].'<br>';             $id[] = $value['id'];             $label[] = $value['label'];             if (!empty($value['items'])) {                 self::recursive_category($value['items'],$indent);             }         };     }     $result = array_combine($id, $label);     return $result;  } 


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -