所以这是我的循环。它工作得很好。但是我需要在这个循环之间放置一个图像(在父级别只有一次)并且循环继续
<?php foreach ($nav as $value){
echo '<li><a href="'.(isset($value->uri) ? $value->uri: '#').'">'.$value->name.'</a>';
if ($value->children->count() > 0){
echo '<ul class="white is-dropdown-submenu menu">';
foreach ($value->children as $child){
echo '<li><a href="'.(isset($child->uri) ? $child->uri: '#').'">'.$child->name.'</a></li>';
}
echo '</ul>';
}
echo '</li>';
}; ?>
答案 0 :(得分:0)
<?php
$counter = 0;
foreach ($nav as $value){
if($counter === 0) { echo "<img/>"; }
echo '<li><a href="'.(isset($value->uri) ? $value->uri: '#').'">'.$value->name.'</a>';a
if ($value->children->count() > 0){
echo '<ul class="white is-dropdown-submenu menu">';
foreach ($value->children as $child){
echo '<li><a href="'.(isset($child->uri) ? $child->uri: '#').'">'.$child->name.'</a></li>';
}
echo '</ul>';
}
echo '</li>';
$counter++;
}; ?>