title: Formatting the results of a MySQL query as if it were run from the console
body: <p>I'm writing a quick and dirty reporting script that queries a report and emails the results. When using the MySQL console the results are in a nicely formatted table:</p>
  
  <pre><code>mysql&gt; select * from users;
  +-----------+------------+-------+
  | firstname | city       | zip   |
  +-----------+------------+-------+
  | Maria     | Holland    | 12345 |
  | Rene      | Doylestown | 65432 |
  | Helen     | Conway     | 98745 |
  +-----------+------------+-------+
  3 rows in set (0.01 sec)
  </code></pre>
  
  <p>Is there an easy way to replicate this formatting when fetching the results with PHP? Obviously I could achieve this by writing my own report formatter but I was hoping for something a little more elegant. </p>