How to get the percentage result by dividing two numbers in php
This article mainly introduces how to get the percentage results by dividing the two numbers in php, which has a certain reference value, and interested friends can refer to it. I hope you will gain a lot after reading this article.
Methods: 1. Multiply the result of the division of two numbers by 100 by using the "*" arithmetic operator to obtain the percentage value of the percentage result, and the syntax is "divisor / divisor * 100". String concatenator, the obtained percentage value will be connected with "%", the syntax is "percentage value."%".
This article operating environment: Windows10 system, PHP7.1 version, Dell G3 computer.
How to get the percentage result by dividing two numbers in php
In php, click "." Refers to a string connector that can concatenate two or more strings into a new string.
The specific syntax format is as follows
$string = string1.string2.string3. .stringn
Divide the two beams to get the percentage result.
Multiply the result of division by 100 to get the percentage value of the percentage result.
Then add the percentage sign after the percentage value.
Examples are as follows:
Output result:
Thank you for reading this article carefully. I hope the article "how to get the percentage result from the division of two numbers in php" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!