Home  >  Article  >  Backend Development  >  PHP decimal conversion percentage function

PHP decimal conversion percentage function

WBOY
WBOYOriginal
2016-07-25 09:10:312090browse
PHP decimal conversion percentage function, interested friends can refer to it. Example 1: Example 2: If you have a novel, there are requirements for the number of digits You can use spring

PHP function for converting decimals into percentages, interested friends can refer to it.

Example 1:

Example 2: If you have a novel, there are requirements for the number of digits You can use sprintf(".2f", $n*100).'%';

Example 3: Round first, then convert $str=round(5.055, 2); // 5.06

$str1=$str."%"; //5.06%

#------------------------ sprintf(".2f", $n*100).'%';



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:PHP JSON to arrayNext article:PHP JSON to array