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.
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!