I hope you're all doing well. I have been working on a small project recently and I'm having some trouble with the array_push() function in PHP. I have an array that I want to add values to using the array_push() function, but instead of appending new elements to the array, it seems to be overwriting the entire array.
Here's a snippet of my code:
$myArray = array("apple", "banana", "cherry");
array_push($myArray, "date", "elderberry", "fig");
Now, according to the PHP documentation, array_push() should add elements to the end of an array. However, when I print out the contents of $myArray, it only shows "date", "elderberry", and "fig", completely replacing the original array.
I've tried searching online for a solution, but I couldn't find anything that addresses this specific issue. I'm wondering if there's something I'm missing or if there's an alternative way to achieve the desired result.
If any of you have experience with PHP and arrays, I would really appreciate any insights or suggestions you might have. Thank you in advance for your help!