array_slice but for images php
问题 i have written this code <?php $a = Meme::all(); $b = count($a); for($i=$b;$i<$b-3;$i--) { ?> <div class="col-sm-6"><img class="lazy" data-src="<?php echo $a[$i]->path; ?>" /> </div> <?php }?> i want to output the last 3 memes(images) but this for loop doesn't work. So i found something that is called array_slice and i wanted to use it but everyone was using print_r but in this case i don't need it. So any suggestions? 回答1: Store those 3 elements of array $a in a new array $b by using array