get first key of array php
snippet in php

get first key of array php

user5854

$firstKey = array_key_first($array);

php get first element of array

user5821

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