PHP How to add to end of array?
In PHP, you can add an element to the end of an array using the array_push() function. The function takes the array as its first argument and the element to add as its second argument. Here's an example:
<?php
$fruits = ["apple", "banana", "cherry"];
array_push($fruits, "orange");
print_r($fruits);You can also use the short array syntax, and the append [] operator.
<?php
$fruits = ["apple", "banana", "cherry"];
$fruits[] = "Orange";
print_r($fruits);After these examples, the $fruits array will now contain the elements: "apple", "banana", "cherry", "orange".