How can PHP beginners avoid errors when using array_push?

When using array_push in PHP, beginners should ensure that the first argument is an array. If the first argument is not an array, PHP will throw an error. To avoid this, beginners should initialize an empty array before using array_push.

// Initialize an empty array
$myArray = [];

// Use array_push to add elements to the array
array_push($myArray, "element1", "element2", "element3");

// Print the array to see the result
print_r($myArray);