Skip to content
Advertisement

array_push(): Argument #1 ($array) must be of type array, string given [closed]

This is my code, and when I run this function I get this: array_push(): Argument #1 ($array) must be of type array, string given I trying to add value to the array

JavaScript

this must be obtained:

JavaScript

Advertisement

Answer

array_push takes an array and a value to add to it. However the more common way would be just:

JavaScript

That being said, there is a built-in function so you don’t have to loop and do it:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement