【发布时间】:2019-09-19 07:44:08
【问题描述】:
我正在尝试删除我的集合中的一个项目,我正在尝试检查当前集合项的特定值是否等于下一个集合项,如果相等则删除下一个。
$path = CanvasPath::where('stream_id', $streamId)->get();
// if in collection $path a value ->path is identical to previous or before remove it
foreach($path as $key => $value) {
$collection = $path->getIterator();
$current = current($collection);
$next = next($collection);
if($current->path == $next->path) {
// remove $next collection
}
}
如何删除该项目?
【问题讨论】:
-
为什么不在它上面应用独特的收藏?
-
@Rahul 嗯,你会怎么做?
-
你想要与
CanvasPath不同的路径??
标签: php laravel collections laravel-5.6