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

PHP decimal conversion percentage function

WBOY
Release: 2016-07-25 09:10:31
Original
2105 people have browsed it
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).'%';



source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template