Home > Article > Backend Development > PHP conversion code between percentage and decimal
This article introduces to you the content of the article about the mutual conversion code between PHP percentage and decimal. It has a good reference value and I hope it can help friends in need.
PHP Percent to decimal conversion:
= "20.544545%" ()/100; 结果:0.20544545
php Decimal to percent conversion function:
没有位数要求: $n*100.'%'; 如果有小说位数有要求 (1)可以用 sprintf("%01.2f", $n*100).'%'; (2)先 四舍五入,后转换 $str=round(5.055, 2); // 5.06 $str1=$str."%"; //5.06% 要用到四舍五入函数round() 示例: $hhl=round(($hh/$totalpj)*100).’%';//好评率 $lhl=round(($lh/$totalpj)*100).’%';//良好率 $ybl=round(($yb/$totalpj)*100).’%';//一般率 $cl=round(($c/$totalpj)*100).’%';//差率 $hcl=round(($hc/$totalpj)*100).’%';//很差率
Related recommendations:
php paging and regular verification code implementation
Summary of functions to find array difference/intersection in php
The above is the detailed content of PHP conversion code between percentage and decimal. For more information, please follow other related articles on the PHP Chinese website!