esedic
10/4/2016 - 4:19 PM

Get first element in the PHP array and show rest of the elements in array

Get first element in the PHP array and show rest of the elements in array

<?php

$images = array("image1.jpg", "image2.jpg", "image3.jpg");

// get first element
$first_image = array_shift(array_values($images));
echo $first_image.'<br>';

// remove first element
unset($images[0]);
foreach($images as $image) {
	echo $image.'<br>';
}

?>