title: Remove trailing zeros from a string
body: <p>I would like to remove trailing zero's according to the following rules:</p>
  
  <ul>
  <li>The input number will always have 4 decimal places </li>
  <li>The output number should always have between 2 and 4 decimals </li>
  <li>If the last two digits after the decimal is a zero, then remove both of them </li>
  <li>If the last digit after the decimal is a zero, then remove it</li>
  </ul>
  
  <p>Examples:</p>
  
  <ul>
  <li>1.0000 -> 1.00</li>
  <li>1.4000 -> 1.40</li>
  <li>1.4100 -> 1.41</li>
  <li>1.4130 -> 1.413</li>
  <li>1.4136 -> 1.4136</li>
  </ul>
  
  <p>I have considered the following:</p>
  
  <pre><code>if (substr($number, -2) == '00') return substr($number, 0, 4);
  if (substr($number, -1) == '0') return substr($number, 0, 5);
  return $number;
  </code></pre>
  
  <p>Are there any better ways of doing this?</p>