Home / PHP Tips Generated By ChatGPT / Getting the Last Element of an Array in PHP Access the last element of an array without removing it. Source Code $fruits = ['apple', 'banana', 'cherry']; $lastFruit = end($fruits); echo $lastFruit; // Outputs: cherry