php array_push() expects parameter 1 to be array, integer given in
<p>I have tried to solve it, but I am lost. Can you see my mistake?</p>

<p>I have something wrong with:</p>

<pre><code>array_push($change_data[$y],$_POST['new']['location'][$y]);
</code></pre>

<p>I get error:</p>

<blockquote>
  <p>array_push() expects parameter 1 to be array, integer given in...</p>
</blockquote>

<p><code>‍$‍‍y</code> is an integer but I need save it there. I need to create array: </p>

<pre><code>$change_data(id =&gt; location = value)

$location_count = count($_POST['new']['id']);           
$change_data=array();  

for($y=0; $y&lt;$location_count;$y++){ 
    if (!empty($_POST['new']['location'])) {
        array_push($change_data,$y);

        if (!empty($_POST['new']['location'][$y])) { 
            array_push($change_data[$y],$_POST['new']['location'][$y]);  
        }
    }
}
</code></pre>