【发布时间】:2023-03-25 10:52:01
【问题描述】:
大家好,我已经用变量 $lastItems 声明了我的帖子
@if($lastItems->total() > 0)
@foreach($lastItems as $item)
@include('._posting.items')
@endforeach
@else
@include('errors.emptycontent')
@endif
我想在每 3 个帖子后添加广告,我使用类似的东西
@if($lastItems->total() > 0)
@foreach($lastItems as $item)
@include('._posting.items')
@endforeach
@if($item = 3)
<img src="link" alt="ads">
@endif
@else
@include('errors.emptycontent')
@endif
但问题是,当我这样尝试时,它会在每个帖子之后显示广告,而不是在 3 个帖子之后。 我做错了什么?
【问题讨论】:
-
我想你可能想仔细看看
@if($item = 3) -
你的意思是“=”到“==”?
标签: php laravel-5 blade laravel-blade