【发布时间】:2021-03-05 11:32:25
【问题描述】:
我有一个名为“images”的数组
array:6 [▼
0 => {#371 ▼
+"id": 15175604535432
+"product_id": 4673356234888
+"position": 1
+"created_at": "2020-03-10T16:52:33-04:00"
+"updated_at": "2020-03-10T16:52:33-04:00"
+"alt": null
+"width": 800
+"height": 800
+"src": "https://cdn.shopify.com/s/files/1/0335/4175/0920/products/product-image-1294465746.jpg?v=1583873553"
+"variant_ids": []
+"admin_graphql_api_id": "gid://shopify/ProductImage/15175604535432"
}
1 => {#372 ▶}
2 => {#373 ▶}
3 => {#374 ▶}
4 => {#375 ▶}
5 => {#376 ▶}
我知道我需要 'id' 值为 15175604535432 的图像 src。
如果我知道 ID 的值,有没有办法获取 src?
我已经尝试过dd($products[1]->images['id'][15175604535432]->src);
和$products[1]->images->where('id',15175604535432)->src 但都没有工作
【问题讨论】:
-
显示您收到的错误。
-
错误:未定义的索引:id 并调用数组上的成员函数 where() 以获取第二个代码
标签: php arrays laravel laravel-blade