title: How to push associative arrays to one 2D array
body: <p>How I can load two associative arrays into an index array through two separate functions like this:</p>
  
  <pre><code> $allData =[];
  
   function func1(){
    $func1_arr = array('a' =&gt; 1, 'b' =&gt; 2, 'c' =&gt; 3, 'd' =&gt; 4, 'e' =&gt; 5);
     array_push($allData, $func1_arr);
  }
  func1();
  
  function func2(){
    $func2_arr = array('a' =&gt; 45, 'b' =&gt; 23, 'c' =&gt; 88, 'd' =&gt; 33, 'e' =&gt; 82);
  array_push($allData, $func2_arr);
  }
  func2();
  
  echo json_encode($allData);
  </code></pre>
  
  <p>I also tried passing the <code>$allData</code> as parameter of <code>func1($allData)</code> and <code>func2($allData)</code> but I am getting empty <code>[ ]</code> in return</p>
  
  <pre><code>$allData =[];
  
  function func1($allData){
    $func1_arr = array('a' =&gt; 1, 'b' =&gt; 2, 'c' =&gt; 3, 'd' =&gt; 4, 'e' =&gt; 5);
     array_push($allData, $func1_arr);
  }
  func1($allData);
  
  function func2($allData){
    $func2_arr = array('a' =&gt; 45, 'b' =&gt; 23, 'c' =&gt; 88, 'd' =&gt; 33, 'e' =&gt; 82);
  array_push($allData, $func2_arr);
  }
  func2($allData);
  
  echo json_encode($allData);
  </code></pre>
  
  <h2>Update</h2>
  
  <p>Here is what I have tried with with <code>return</code></p>
  
  <pre><code>$allData =[];
  
  function func1($allData){
    $func1_arr = array('a' =&gt; 1, 'b' =&gt; 2, 'c' =&gt; 3, 'd' =&gt; 4, 'e' =&gt; 5);
     return array_push($allData, $func1_arr);
  }
  func1($allData);
  
  function func2($allData){
    $func2_arr = array('a' =&gt; 45, 'b' =&gt; 23, 'c' =&gt; 88, 'd' =&gt; 33, 'e' =&gt; 82);
   return array_push($allData, $func2_arr);
  }
  func2($allData);
  
  echo json_encode($allData);
  </code></pre>
  
  <p>and still getting empty array in result</p>
  
  <pre><code>$allData =[];
  
  function func1($allData){
    $func1_arr = array('a' =&gt; 1, 'b' =&gt; 2, 'c' =&gt; 3, 'd' =&gt; 4, 'e' =&gt; 5);
      array_push($allData, $func1_arr);
      return $allData;
  }
  func1($allData);
  
  function func2($allData){
    $func2_arr = array('a' =&gt; 45, 'b' =&gt; 23, 'c' =&gt; 88, 'd' =&gt; 33, 'e' =&gt; 82);
    array_push($allData, $func2_arr);
    return $allData;
  }
  func2($allData);
  
  echo json_encode($allData);
  </code></pre>