Get the App
SLTechnology News&Howtos  ›  Development  › 

How to get the percentage result by dividing two numbers in php

Shulou Source: shulou.com Published: 2022-06-01 13:09:18 10月04日 Update

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!

Tags: Percentage result two percentage numeric value character string article grammar percentage value interest at the same time method more friends format environment computer percent sign Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Redmi Docker Microsoft Apple