Home Backend Development PHP Tutorial 求大侠,数字转换钱币。该如何处理

求大侠,数字转换钱币。该如何处理

Jun 13, 2016 pm 01:40 PM
format str

求大侠,数字转换钱币。
如何把数字转换成钱币那样子? 
比如 10000 转成 10,000.00

求大侠解决方案。

------解决方案--------------------

探讨

引用:

引用:

引用:

$str='10000';
echo number_format($str,2,'.',',');

10,000.00


如果不定的位数,用str_length 来判断格式化吧?


啥意思.


如果是1000000,1000……
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP formats a GMT/UTC date/time PHP formats a GMT/UTC date/time Mar 21, 2024 am 10:41 AM

This article will explain in detail how to format a GMT/UTC date/time with PHP. The editor thinks it is quite practical, so I share it with you as a reference. I hope you can gain something after reading this article. Introduction to Formatting GMT/UTC Date/Time in PHP In PHP, formatting GMT/UTC date/time is crucial for correctly displaying and handling cross-time zone dates. This article will explain how to format a GMT/UTC date/time using PHP's DateTime class, as well as the various formatting options available. DateTime class The DateTime class represents a date and time. It can store and manipulate date/time values ​​in time zones such as GMT/UTC. To create a new Da

Python built-in type str source code analysis Python built-in type str source code analysis May 09, 2023 pm 02:16 PM

1The basic unit of Unicode computer storage is the byte, which is composed of 8 bits. Since English only consists of 26 letters plus a number of symbols, English characters can be stored directly in bytes. But other languages ​​(such as Chinese, Japanese, Korean, etc.) have to use multiple bytes for encoding due to the large number of characters. With the spread of computer technology, non-Latin character encoding technology continues to develop, but there are still two major limitations: no multi-language support: the encoding scheme of one language cannot be used in another language and there is no unified standard: for example There are many encoding standards in Chinese such as GBK, GB2312, GB18030, etc. Since the encoding methods are not unified, developers need to convert back and forth between different encodings, and many errors will inevitably occur.

What does format in python mean? What does format in python mean? Jul 31, 2023 pm 02:02 PM

format in Python is a string formatting method used to insert variables or values ​​into placeholder positions in a string. Through the format method, we can dynamically construct a string to contain different values.

What does format mean in python What does format mean in python Jul 31, 2023 pm 02:05 PM

In Python, `format` is a built-in function used to format strings. It is used to create a string template with placeholders and fill the placeholders with specified values. This allows strings to be constructed dynamically based on different situations, making the output more readable and customizable.

What is the usage of format in python What is the usage of format in python Jul 31, 2023 pm 01:59 PM

The usage of format in python is basic usage, specifying location, specifying variable name, formatting numbers, formatting date and time.

What are the similarities and differences between __str__ and __repr__ in Python? What are the similarities and differences between __str__ and __repr__ in Python? Apr 29, 2023 pm 07:58 PM

What are the similarities and differences between __str__ and __repr__? We all know the representation of strings. Python's built-in function repr() can express objects in the form of strings to facilitate our identification. This is the "string representation". repr() obtains the string representation of an object through the special method __repr__. If __repr__ is not implemented, when we print an instance of a vector to the console, the resulting string may be. >>>classExample:pass>>>print(str(Example()))>>>

How to convert a string into formatted date and time in MySQL How to convert a string into formatted date and time in MySQL Jun 01, 2023 pm 09:22 PM

STR_TO_DATE(date, format): Convert the string into the date and time in format SELECTSTR_TO_DATE(‘2015-01-01’,‘%Y-%m-%d’)->2015-01-01

String formatting in Python: How to use the format() function String formatting in Python: How to use the format() function Apr 22, 2023 pm 07:01 PM

Method of inserting variables into a string The format() function in Python is a method of inserting variables into a string, which can make the string easier to read and understand. It supports many different usages. The following are specific usages and instructions: Use positional parameters to pass variables name='John'age=25print('Mynameis{},andIam{}yearsold.'.format(name,age))#output :MynameisJohn,andIam25yearsold. Use the index to pass the variable name='

See all articles