Reputation: 1032
I have 5 images. I need to show the images based on the order.
Now I have the order in the array like
2,3,5,1,4
Now my images are in $new->image1,$new->image2,$new->image3,$new->image4,$new->image5
My result should be like if order is as like above,
order is like $new->image2,$new->image3,$new->image5,$new->image5,$new->image1,$new->image4
How can I achieve this
<table style="text-align:justify" align="center" border="1" cellspacing="0" >
{{$new->img_order}}
<?php
$order_array = explode(",", $new->img_order);
$img1 = $new->image2;
dd($new->image2);
?>
<tr>
<td height="600" rowspan="3"><img width="350" height="910px" src="{{asset('collage/'.$new->image1)}}" class="img-responsive" alt=""></td>
<td height="300" colspan="2"><img width="500" height="300px" src="{{asset('collage/'.$new->image2)}}" class="img-responsive" alt=""></td>
</tr>
<tr>
<td width="250" ><img width="250" height="350px" src="{{asset('collage/'.$new->image3)}}" class="img-responsive" alt=""></td>
<td width="250"><img width="250" height="350px" src="{{asset('collage/'.$new->image4)}}" class="img-responsive" alt=""></td>
</tr>
<tr>
<td colspan="2"><img width="500" height="250px" src="{{asset('collage/'.$new->image5)}}" class="img-responsive" alt=""></td>
</tr>
</table>
Upvotes: 1
Views: 631
Reputation: 28529
I just wonder why you not save the image path in array, but with many image1, image2, ....
.
Without sorting the image, you can echo the image by the order array with
$new->{'image' . $order[0]}
$new->{'image' . $order[1]}
$new->{'image' . $order[2]}
...
Upvotes: 3