gpt4 book ai didi

php - 如何 array_values laravel 集合?

转载 作者:可可西里 更新时间:2023-11-01 00:29:40 25 4
gpt4 key购买 nike

我有一个来自 image 模型的搜索结果,$photo 保存了 $photo->type == 'photo' 的数据。

$photo = $image->filter(function($photo,$key) use($path){
if($photo->type == 'photo'){
$photo->url = $path.$photo->image;
return $photo;
}
});

这是 $photo 集合,有什么方法可以array_values() items 数据吗?

Collection {#352 ▼
#items: array:3 [▼
2 => ImageBanquet {#349 ▶}
3 => ImageBanquet {#350 ▶}
4 => ImageBanquet {#351 ▶}
]
}

最佳答案

检查 values()收藏 helper 。

$values = $collection->values();

关于php - 如何 array_values laravel 集合?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40626134/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com