I think the key problem is defining how many positions are needed. Would you define 13.01 as 13 because the first decimal was a 0? Since printf and number format needs you to know how many decimals, I don't know that that would work for you.
Maybe something like this (which is a lot of functions, but looks for the first 0, and then returns the truncated string). Yes, it is intensive, but it may be the best way for you.
function show_number($number, $max = 8){
if(strpos($number, '.')){
$decimal = strpos($number, '.');
if(strpos($number, '.0')){
return substr($number, 0, $decimal);//returns whole if zero is first
} else {
if(strpos(substr($number, $decimal, $max), '0')){
$zero = strpos(substr($number, $decimal, $max), '0');
return substr($number, 0, $decimal+$zero);//returns number w/0 first zero
} else {
return substr($number, 0, $decimal+$max+1); //returns number with max places
}
}
} else {
return $number; //returns number if no decimals
}
}