在foreach循环PHP中,Multiplay爆炸

在foreach循环PHP中,Multiplay爆炸,php,html,laravel,Php,Html,Laravel,我从Yahoo获得了这个API,我想用它创建面包屑: 因此,xml结果如下所示: <CategoryPath>Auction > Conputer > PC</CategoryPath> <CategoryIdPath>0,23336,2084039759</CategoryIdPath> Auction>Conputer>PC 0,23336,2084039759 我想创建的是面包屑 <ul class="breadcrum

我从Yahoo获得了这个API,我想用它创建面包屑:

因此,xml结果如下所示:

<CategoryPath>Auction > Conputer > PC</CategoryPath>
<CategoryIdPath>0,23336,2084039759</CategoryIdPath>
Auction>Conputer>PC
0,23336,2084039759
我想创建的是面包屑

<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>
当然,每次都会有不同的值,所以我需要分解它们,并将这两个分解放在一个foreach循环中。但我不知道怎么做

有人能告诉我怎么做吗?或者展示一种不同的方法吗?

先获取阵列:

$category_path = explode(' > ', $xml->Result->CategoryPath);
$category_path_id = explode(',', $xml->Result->CategoryIdPath);
然后将它们结合起来:

$breadcrumbs = array_combine($category_path_id, $category_path);
然后循环它们(我使用Laravel刀片模板):

    @foreach($id=>$name的面包屑)
  • @endforeach

分解它们两个>>阵列组合>>循环和output@hassan非常感谢。数组\u组合如果你已经想出了怎么做,就发布一个答案来整理这个问题。@NigelRen做到了!
<ul class="breadcrumb">
    @foreach($breadcrumbs as $id => $name)
       <li><a href="?category={{ $id }}">{{ $name }}</a></li>
    @endforeach
</ul>