Here My Codes That Fetch All Images
@foreach (explode('|', $product->images) as $image) <img style="width:100%" src="/storage/image/{{$image}}"> @endforeach
Only I want To Display the first image from this array How Can i Do That
Here My Codes That Fetch All Images
@foreach (explode('|', $product->images) as $image) <img style="width:100%" src="/storage/image/{{$image}}"> @endforeach
Only I want To Display the first image from this array How Can i Do That
2
Answers
I hope this helps.
So, if you’re passing the array from your controller to view/blade page then you should just do.
img src="/storage/image/{{$image[0]}}"
E.g $images = [
‘image1.jpg’,
‘image2.jpg’,
‘image3.png’,
‘etc.jpg’
]
Then you pass $images
:Then call $images[1]