0

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
  • Laravel has a $loop variable you could use Commented Feb 25, 2024 at 10:11
  • Explode the array and use array notation? Commented Feb 25, 2024 at 11:01

1 Answer 1

0

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]

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.