Home  >  Article  >  Backend Development  >  How to convert php 50.00 to 50

How to convert php 50.00 to 50

藏色散人
藏色散人Original
2021-09-16 10:39:242140browse

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.

How to convert php 50.00 to 50

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 &#39;50&#39; (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!

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