php get first key of array
snippet in php

get first key of array php

user5634

$firstKey = array_key_first($array);

php get first key of array

user5985

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