What are some best practices for adding new entries to an array in PHP?

When adding new entries to an array in PHP, it is best practice to use the array_push() function to append new elements to the end of the array. This function ensures that the new entry is added without overwriting existing elements and maintains the integrity of the array structure.

// Initialize an array
$array = [1, 2, 3, 4];

// Add a new entry to the array using array_push()
$newEntry = 5;
array_push($array, $newEntry);

// Output the updated array
print_r($array);