Home >Backend Development >PHP Problem >How to convert decimal from integer in php

How to convert decimal from integer in php

藏色散人
藏色散人Original
2020-08-08 09:47:142965browse

php method to convert integers to decimals: first create a PHP sample file; then implement the conversion through the "sprintf('%.2f',$memrow['yjrebate1'] $memrow['yjrebate2'])" method That’s it.

How to convert decimal from integer in php

Recommended: "PHP Video Tutorial"

PHP integer to decimal conversion

sprintf('%.2f',$memrow['yjrebate1']+$memrow['yjrebate2'])

Related introduction:

sprintf() function writes the formatted string into a variable.

arg1, arg2, parameters will be inserted into the main string at the percent sign (%) symbol. This function is executed step by step. At the first % sign, insert arg1, at the second % sign, arg2, and so on.

Note: If there are more % symbols than arg arguments, you must use placeholders. The placeholder is inserted after the % symbol and consists of a number and "\$". See Example 2.

Tip: Related functions: printf(), vprintf(), vsprintf(), fprintf(), and vfprintf()

Syntax

sprintf(format,arg1,arg2,arg++)

The above is the detailed content of How to convert decimal from integer 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