title: Saving foreach output as a string variable?
body: <p>I am looping through a SQL query and I would like to grab that output and save it as a string variable.. is this possible?</p>
  
  <p>My loop is as follows:</p>
  
  <pre><code> foreach ($dbh-&gt;query($sql2) as $row2) {
          echo $row2['id'];
          echo $row2['staff'];
          echo $row2['dept'];
      }
  </code></pre>
  
  <p>And I would like to save all of the output as one string variable ie <code>$output</code></p>