How to convert decimal from integer in php

藏色散人
Release: 2023-03-04 06:44:01
Original
2912 people have browsed it

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'])
Copy after login

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++)
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!