php get first element of array
snippet in php

php get first element of array

user7891

$colors = array(2=>"blue",3 =>"green",1=>"red");
$firstValue = reset($colors); //blue
$firstKey = key($colors); //2

first item in array php

user3589

$firstItem = array_shift($array);