I have this API from Yahoo and I want to create Breadcrumb use it:
So xml result is like this:
<CategoryPath>Auction > Conputer > PC</CategoryPath>
<CategoryIdPath>0,23336,2084039759</CategoryIdPath>
What I want to create is Breadcrumb
<ul class="breadcrumb">
<li><a href="o">Auction</a></li>
<li><a href="23336">Conputer</a></li>
<li><a href="2084039759">PC</a></li>
</ul>
Of Course every time it will be different values, so I need to explode them and put this two explodes in one foreach loop. But I don't have any idea how to do it...
Can someone show me how can i do it or show a different approach?
First get arrays:
$category_path = explode(' > ', $xml->Result->CategoryPath);
$category_path_id = explode(',', $xml->Result->CategoryIdPath);
Then combine them:
$breadcrumbs = array_combine($category_path_id, $category_path);
Then loop them(i use Laravel Blade template):
<ul class="breadcrumb">
@foreach($breadcrumbs as $id => $name)
<li><a href="?category={{ $id }}">{{ $name }}</a></li>
@endforeach
</ul>