I want to convert this php code snippet that converts/truncates a value:
here is the php code:
$currentcost = 42.35;
$currentcost = explode(".", $currentcost);
if($currentcost[1] <= 35) {
$currentcost[1] = 99;
$currentcost[0] -= 1;
}
echo $output = $currentcost[0] . "." . $currentcost[1];
This is supposed to be the condition:
x.35 where x is any number. If the decimal number is less than or equal to 35 then convert the .35 into 99 and subtract the x value with 1.
Something like this:
42.35 will become 41.99