Laravel PHP get value in array

  arrays, laravel, laravel-blade, php

I have this array called "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 ▶}

and I know that I need src of images where ‘id’ has value 15175604535432.

Is there a way to get src if I know value of ID?

I already try dd($products[1]->images['id'][15175604535432]->src);
and $products[1]->images->where('id',15175604535432)->src but both didnt work

Source: Laravel

Leave a Reply