I want to create a “guide bar” (I don’t know its right name). I’ve got a table called cat that has the following data:
catid catname parentid 1 news null 2 sport 1 3 health 1 4 tennis 2 5 football 2 6 soccer 5
My page receives: $catid=6, and I want to create:
news>sport>football>soccer
First get your data from database and build an array
Use a recursive function to build the breadcrumbs:
The function returns the parent’s breadcrumbs + the current breadcrumb. Use the function like this:
Or, if you like arrays more, you can create a function like this:
and use it with implode:
That gives you the option to define the separator outside the function. Hope that helps.