title: How do I truncate a decimal in PHP?
body: <p>I know of the PHP function <code>floor()</code> but that doesn't work how I want it to in negative numbers.</p>
  
  <p><strong>This is how floor works</strong></p>
  
  <pre><code>floor( 1234.567); //  1234
  floor(-1234.567); // -1235
  </code></pre>
  
  <p><strong>This is what I WANT</strong></p>
  
  <pre><code>truncate( 1234.567); //  1234
  truncate(-1234.567); // -1234
  </code></pre>
  
  <p>Is there a PHP function that will return -1234?</p>
  
  <p>I know I could do this but I'm hoping for a single built-in function</p>
  
  <pre><code>$num = -1234.567;
  echo $num &gt;= 0 ? floor($num) : ceil($num);
  </code></pre>