One way is to cast it to float:
$num1 = '4.0';
$num2 = '5.5550';
echo (float) $num1; // 4
echo "<br />\n";
echo (float) $num2; // 5.555
Another option is to use round(), if you want to limit the max number of decimal places:
$num1 = '4.0';
$num2 = '5.5550';
echo round($num1, 2); // 4
echo "<br />\n";
echo round($num2, 2); // 5.56 (note rounding up in this case)