Array_slice returns the value & ldquo; array & rdquo;


I'm trying to display an image on screen by reading the contents and array and using that value to fill in part of the file name.

In the code below the array has 3 values, 100, 101 and 102. I'm trying to take the first value "100" to output

If I just set $image to the value of "100" it works fine. When I set $image as an array_slice, and echo $image, it returns "array" instead of "100".


$dirname = "images/wrf/";
$array=array("100", "101", "102");
$image = array_slice($array, 0, 1);

echo '<img src="' . $dirname . 'wrf' . $image . 'medium.jpg">';

//out put for debugging
echo "contents of image===";
echo $image;


array_slice result is array according to the docs,

if you'd like to get one element of array use [] operator instead

$image = $array[0];