Using array_push() to add elements to an array in the form of 'key => object'
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/2973202/mysql-fetch-array-expects-parameter-1-to-be-resource-boolean-given-in-select">mysql_fetch_array() expects parameter 1 to be resource, boolean given in select</a>  </p>
</blockquote>



<p>I have a set of objects I want to put into an array and I want to distinguish them with keys.</p>

<p>The initial code I wrote was:</p>

<pre><code>array_push($array[$key], new myObj(param1, param2, etc));
</code></pre>

<p>When I run it I get the warning:</p>

<pre><code>PHP Warning:  array_push() expects parameter 1 to be array, null given in file.php on line 56
</code></pre>

<p>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.</p>

<p>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'.</p>
