How to convert php 50.00 to 50: 1. Create a PHP sample file; 2. Convert 50.00 to 50 directly through the "var_dump(sprintf("%d", 50.00)); method.
The operating environment of this article: Windows7 system, PHP7.1 version, Dell G3 computer
How to convert php 50.00 to 50?
The code is as follows:
<?php var_dump(sprintf("%d", 50.00));
The output result is:
string '50' (length=2)
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.
Tips: Related functions: printf(), vprintf(), vsprintf(), fprintf() and vfprintf()
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to convert php 50.00 to 50. For more information, please follow other related articles on the PHP Chinese website!