Home>Article>Backend Development> How to convert decimal to percentage in php

How to convert decimal to percentage in php

WBOY
WBOY Original
2021-12-02 10:14:34 2514browse

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.

How to convert decimal to percentage in php

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:

How to convert decimal to percentage in php

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!

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