This is my code, and when I run this function I get this :Warning: array_push() expects parameter 1 to be array However I define $printed as an array
Instead of the function array_push() use $your_array[] = $element_to_be_added; when you want to add a single element to the array.
As mentioned in the docs, this creates a new array, if the array is null:
Note: If you use array_push() to add one element to the array it's better to use $array[] = because in that way there is no overhead of calling a function.
and:
Note: array_push() will raise a warning if the first argument is not an array. This differs from the $var[] behaviour where a new array is created.
from: http://php.net/manual/en/function.array-push.php