$field_array1 = array( 'a' => 1, 'b' => 1, 'c' => 1, 'd' => 1, ); foreach(array_keys($field_array1) as $key){ echo $key."\n"; } $array = array('first'=>'111', 'second'=>'222', 'third'=>'333'); // get the first key: returns 'first' print array_shift(array_keys($array)); // get the last key: returns 'third' print array_pop(array_keys($array)); // get the first value: returns '111' print array_shift(array_values($array)); // get the last value: returns '333' print array_pop(array_values($array));