$languages = [   'JAVA',   'PHP',   'C++',   'C#',   'Python', ]; $totalElements = count($languages); echo $languages[$totalElements - 1]; 

Read more of this post