使用PHP格式化0的简单问题
我试着取一个像“2.4”这样的字符串,然后递增超过2.9到2.10,2.11等等。请协助,已经搜索了两天了!这是我最后一次绝望的尝试使用PHP格式化0的简单问题,php,loops,Php,Loops,我试着取一个像“2.4”这样的字符串,然后递增超过2.9到2.10,2.11等等。请协助,已经搜索了两天了!这是我最后一次绝望的尝试 $update =$note;// (float) $note; for($x=1;$x<sizeof($index);$x++){ if(preg_match("/\.9/s", $update)){ $u = explode(".", $update); $update
$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";
}
}
$update=$note;//(浮动)美元钞票;
对于($x=1;$x请尝试以下方法:
$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);
}
$string=“2.42”;
$nums=explode(“.”,$string);
$total=$nums[0];
$decimals=intval($nums[1]);
$add_倍=10;
对于($i=0;$i<$add_倍;$i++){
$decimals+=1;
$final_num=floatval($total.“.”$decimals);
变量转储(最终数量);
}
所以你想添加。1但什么时候停止添加?是的,保留右填充0。否。它是int(1)int(2)int(3)int(4)int(5)int(6)int(7)int(8)int(9)int(10)0.1ok,然后将连接放在迭代中。尝试我更新的代码。