get first element of associative array php code example
Example 1: first item in array php
$firstItem = array_shift($array);
Example 2: php get first element of array
$colors = array(2=>"blue",3 =>"green",1=>"red");
$firstValue = reset($colors);
$firstKey = key($colors);
Example 3: php add element to beginning of associative array
$arr1 = array('key0' => 'value0') + $arr1;
-------------- OR ------------------
<?php
$arr = array('key1' => 'value1', 'key2' => 'value2');
$arr = array_merge(array('key0' => 'value0'), $arr);