title: Return all arrays inside foreach loop
body: <p>How to return all array values inside foreach loop. Return is working fine and no error but is only one record. If i have 10 records in database, It supposed to be all records. What did i missed this code? thanks for your help.</p>
  
  <p>PHP </p>
  
  <pre><code>function myfunction(){
      $query ="SELECT * from tbl_data";
      $stmt = $this-&gt;getConnection()-&gt;prepare($query);
      $stmt-&gt;execute();
  
      foreach ($stmt-&gt;fetchAll() as $value) {
  
          //custom value
          $customval = 1;
  
          $array = array([
              "ID"                =&gt; $value['ID'],
              "name"              =&gt; $value['name'],
              "staus"             =&gt; $value['status'],
              "customval"         =&gt; $customval,
          ]);
      }
  
      return $array;
  }
  </code></pre>