Home > Backend Development > PHP Problem > How to convert php 50.00 to 50

How to convert php 50.00 to 50

藏色散人
Release: 2023-03-12 15:52:01
Original
2202 people have browsed it

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

The output result is:

string &#39;50&#39; (length=2)
Copy after login

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!

Related labels:
php
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