title: Sort by date when using foreach
body: <p>I am creating a page to list select columns from each row in a table.  I have the basics of that down by using a foreach loop as below and it works fine.  The problem I am up against now is that I need to order the results by date (one of the columns) with the newest record being at the top.</p>
  
  <p>This is what I have so far (that works but without sorting)</p>
  
  <pre><code>foreach ($visitors as $visitor) {
          $id = htmlentities($visitor['family_id']);
          $first_name = htmlentities($visitor['first_name']);
          $last_name = htmlentities($visitor['last_name']);
          $visit_date = htmlentities($visitor['visit_date']);
          $phone = htmlentities($visitor['phone']);
          $email = htmlentities($visitor['email']);
          ?&gt;
  
          &lt;p&gt;&lt;?php echo $visit_date; ?&gt;&lt;a href="visitor-view.php?id=&lt;?php echo $id; ?&gt;"&gt; &lt;?php echo $first_name . ' ' . $last_name; ?&gt;&lt;/a&gt; &lt;?php echo $phone; echo $email; ?&gt;&lt;/p&gt;
          &lt;?php
      } 
  </code></pre>
  
  <p>Hoping someone has a bright idea as to how to get it to sort.</p>