title: php strip leading zeros and 0 decimal values
body: <p>This falls into the category of 'I'm sure there is a cleaner way to do this' although it works perfectly well. Maybe some kind of function.</p>
  
  <p>I have lists of values such as 
  01.0, 
  09.5, 
  10.0, 
  11.5, </p>
  
  <p>I want the values to always exclude the leading 0 and only keep the decimal portion if it it contains a .5. There will never be any other decimal value. My current code is:</p>
  
  <pre><code>$data = '09.5'; //just an example value
  
  if (substr($data,0,1) == '0' ) {
      $data = substr($data, 1);
  }
  if (stripos($data, '.0') !== FALSE ) {
      $data = str_replace('.0','',$data);
  }
  print $data;
  </code></pre>