↧
Answer by viral for Get path from adjacency list data
Consider this array,$input = [ ['id'=>1, 'name'=>'Anniversary', 'parent'=>0], ['id'=>12, 'name'=>'New arrives', 'parent'=>1], ['id'=>13, 'name'=>'Discount', 'parent'=>12],...
View ArticleAnswer by Narendrasingh Sisodia for Get path from adjacency list data
function getpath($id, $arr, $level = 0) { $result = array(); foreach($arr as $key => $value){ if($id == $value['id']){ $result[] = $value['name']; $id = $value['parent']; if($id != 0){ $result =...
View ArticleAnswer by splash58 for Get path from adjacency list data
$find = 13;$path = array();function FindById ($arr, $find) { $k = null; foreach($arr as $key => $item) if ($item['id'] == $find) { $k = $key; break; } return $k;}if ( false === ($k = FindById($arr,...
View ArticleGet path from adjacency list data
I have an array (data from adjacency table) and it looks like:Array( [0] => Array ( [id] => 1 [name] => Anniversary [parent] => 0 ) [1] => Array ( [id] => 12 [name] => New arrives...
View Article
More Pages to Explore .....