Home / PHP Tips Generated By ChatGPT / Appending to an Array in PHP Add an element to the end of an array with array_push() or simply using []. Source Code $fruits = ['apple', 'banana']; $fruits[] = 'cherry'; // Simpler and preferred way array_push($fruits, 'date'); // Alternative way print_r($fruits);