php foreach如果存在则获得其他值之后的值

时间:2019-05-05 08:51:22

标签: php laravel foreach

我需要在$level_task->task_name==$task->task_name之后获取数组中的下一个值,以便为下一个任务建立链接

@foreach ($tasks as $level_task)

    @if ($level_task->task_name==$task->task_name)
        <a href="{{route('task', ['category' =>$level_task->path->category->slug,'level'=>$level_task->task_level,'path'=>$level_task->path->slug,'slug' => $level_task->slug])}}" class="list-group-item list-group-item-action {{$level_task->task_name==$task->task_name ? "active":""}}">{{$level_task->task_name}}</a>
    @elseif  ($level_task->task_name!=$task->task_name)
        <a href="{{route('task', ['category' =>$level_task->path->category->slug,'level'=>$level_task->task_level,'path'=>$level_task->path->slug,'slug' => $level_task->slug])}}" class="list-group-item list-group-item-action {{$level_task->task_name==$task->task_name ? "active":""}}">{{$level_task->task_name}}</a>
    @endif

@endforeach

0 个答案:

没有答案