I have a set of objects I want to put into an array and I want to distinguish them with keys.
The initial code I wrote was:
array_push($array[$key], new myObj(param1, param2, etc));
When I run it I get the warning:
PHP Warning: array_push() expects parameter 1 to be array, null given in file.php on line 56
I added a var_dump() to see what was actually happening and it was filling the array with each element '$key => null' as suggested by the error.
If I remove the [$key] from the line then it fills the array with instances of myObj as expected so I know that the constructor is functioning correctly and not really returning 'null'.