$foo = array(); $foo[1] = "a"; $foo[2] = "b"; $foo[0] = "c"; echo (is_first_element(0, $foo) ? "true" : "false"); function is_first_element($index, $array) { reset($array); if (key($array) == $index) { return true; } else { return false; } }