Home>Article>Backend Development> How to convert decimal to percentage in php
How to convert decimals into percentages in php: 1. Use the "$str*100" statement to multiply the decimal by 100 and obtain the percentage value after converting the decimal into a percentage; 2. Use "$str1= (Percent value). The "%";" statement adds a percent sign after the obtained value, and uses echo to output the converted percentage.
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
How to use decimals in php Convert to percentage
In PHP we can use the "$str1=($str*100)."%";" statement to convert decimals into percentages.
We first multiply the decimal by 100 and then add the percent sign.
The example is as follows:
Output result:
If you are interested, you can click on "PHP Video Tutorial》Learn more about PHP knowledge.
The above is the detailed content of How to convert decimal to percentage in php. For more information, please follow other related articles on the PHP Chinese website!