我正在尝试像#34; 2.4"并且增加2.9到2.10,2.11以及fowarth。请协助,进行了两天的搜索!这是我最后一次绝望的尝试。
$update =$note;// (float) $note;
for($x=1;$x<sizeof($index);$x++){
if(preg_match("/\.9/s", $update)){
$u = explode(".", $update);
$update = number_format($u[0]+".10", 2);
}else{
$u = explode(".", $update);
if(strlen($u[1])==2){
$add + $u[2]+="1";
$update = "{$u[0]}"."."."{$u[1]}{$add}";
}else{
$update += ".1";
}
}
echo $update."\r";
}
}
答案 0 :(得分:0)
试试这个:
$string = "2.42";
$nums = explode(".", $string);
$whole = $nums[0];
$decimals = intval($nums[1]);
$add_times = 10;
for ($i = 0; $i < $add_times; $i++) {
$decimals += 1;
$final_num = floatval($whole . "." . $decimals);
var_dump($final_num);
}