title: PHP Stripping leading zeros 0 from a number
body: <p>I am posting this as this isn't something most newbies may be familiar with. </p>
  
  <p><strong>The Problem</strong></p>
  
  <p>We have a ticketing system which makes use of a numeric id. Now some people in the company prefer to pre-pend zeroes to the ticket number and some people would reference it without the leading zeroes which is the correct way. So to standardize the output we have to remove the leading zeroes. </p>
  
  <p>This may sound simple to do, but we can't merely run a str_replace over it as this may remove valid 0's in the middle of the number.</p>
  
  <p>Now you could preg match and do all sorts of funky things to find the answer, but the simplest is to merely cast the numeric string to an int. </p>
  
  <p>Let's user the following as an example:</p>
  
  <pre><code>&lt;?php
      $correct = 45678;
      $incorrect = 0045678;
  
      echo $correct . '&lt;br /&gt;';
      echo $incorrect;
  ?&gt;
  </code></pre>
  
  <p>And you should get the following printed out:</p>
  
  <p>45678</p>
  
  <p>0045678</p>
  
  <p>Now essentially these are the same for the application, but I would like to be able to cater for people entering the information in the incorrect format. </p>