Quantcast
Channel: Get path from adjacency list data - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Get path from adjacency list data

$
0
0

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            [parent] => 1        )    [2] => Array        (            [id] => 13            [name] => Discount            [parent] => 12        )    [3] => Array        (            [id] => 6            [name] => Birthday            [parent] => 0        ))

And I'm looking for the way to retrieve my path by ID;

For example: getPath(13): Anniversary->New arrives->Discount;For example: getPath(12): Anniversary->New arrives;For example: getPath(1): Anniversary;For example: getPath(6): Birthday;

How can I do this?Thanks!


Viewing all articles
Browse latest Browse all 4

Trending Articles





<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>