Qua bài viết này tôi đã chia sẻ đến bạn mã code của hàm hiển thị dữ liệu theo định dạng tiền tệ. Việc của bạn bây giờ hãy copy nó đưa vào và sử dụng trên dự án của mình.
<?php
echo currency_format(37, 'USD');
?>
— Formats a number as a currency string
(PHP 4 >= 4.3.0, PHP 5, PHP 7)
money_format — Formats a number as a currency string
Warning
This function has been DEPRECATED as of PHP 7.4.0, and REMOVED as of PHP 8.0.0. Relying on this function is highly discouraged.(string <?php
echo currency_format(5000000);
?>
4, float <?php
/**
*
* Chuyển đổi chuỗi kí tự thành dạng slug dùng cho việc tạo friendly url.
*
* @access public
* @param string
* @return string
*/
if (!function_exists('currency_format')) {
function currency_format($number, $suffix = 'đ') {
if (!empty($number)) {
return number_format($number, 0, ',', '.') . "{$suffix}";
}
}
}
3): string
Description
money_format(string <?php
echo currency_format(5000000);
?>
4, float <?php
/**
*
* Chuyển đổi chuỗi kí tự thành dạng slug dùng cho việc tạo friendly url.
*
* @access public
* @param string
* @return string
*/
if (!function_exists('currency_format')) {
function currency_format($number, $suffix = 'đ') {
if (!empty($number)) {
return number_format($number, 0, ',', '.') . "{$suffix}";
}
}
}
3): stringParameters
<?php
echo currency_format(5000000);
?>
6 The format specification consists of the following sequence:
a
<?php
echo currency_format(5000000);
?>
7 characteroptional flags
optional field width
optional left precision
optional right precision
a required conversion character
Flagsf One or more of the optional flags below can be used: f to be used as the numeric fill character. The default fill character is space.
<?php
echo currency_format(5000000);
?>
8f The character
<?php
echo currency_format(5000000);
?>
8 followed by a (single byte) character f to be used as the numeric fill character. The default fill character is space. 5.000.000đ
0 Disable the use of grouping characters (as defined by the current locale).
5.000.000đ
1 or 5.000.000đ
2 Specify the formatting style for positive and negative numbers. If
5.000.000đ
1 is used, the locale's equivalent for 5.000.000đ
1 and 5.000.000đ
5 will be used. If 5.000.000đ
2 is used, negative amounts are enclosed in parenthesis. If no specification is given, the default is 5.000.000đ
1. 5.000.000đ
8 Suppress the currency symbol from the output string.
5.000.000đ
5
If present, it will make all fields left-justified (padded to the right), as opposed to the default which is for the fields to be right-justified (padded to the left). Field width
w
A decimal digit string specifying a minimum field width. Field will be right-justified unless the flag 5.000.000đ
5 is used. Default value is 0 (zero). nLeft precisionn) expected to the left of the decimal character (e.g. the decimal point). It is used usually to keep formatted output aligned in the same columns, using the fill character if the number of digits is less than n. If the
number of actual digits is bigger than n, then this specification is ignored.
<?php
echo currency_format(37, 'USD');
?>
1n The maximum number of digits (n) expected to the left of the decimal character (e.g. the decimal point). It is used usually to keep formatted output aligned in the same columns, using the fill character if the number of digits is less than n. If the number of actual digits is bigger than n, then this specification is ignored.
If grouping has not been suppressed using the 5.000.000đ
0 flag, grouping separators will be inserted before the fill characters (if any) are added. Grouping separators will not be applied to fill characters, even if the fill character is a digit.
To ensure alignment, any characters appearing before or after the number in the formatted output such as currency or sign symbols are padded as necessary with space characters to make their positive and negative formats an equal length. p Right precision p) after the decimal character. If the value of p is 0 (zero), the decimal character and the digits to its right will be omitted. If no right precision is included, the default will dictated by the current locale in use. The amount being formatted is rounded to the specified
number of digits prior to formatting.
<?php
echo currency_format(37, 'USD');
?>
3p
A period followed by the number of digits (p) after the decimal character. If the value of p is 0 (zero), the decimal character and the digits to its right will be omitted. If no right precision is included, the default will dictated by the current locale in use. The amount being formatted is rounded to the specified number of digits prior to formatting. Conversion characters
<?php
echo currency_format(37, 'USD');
?>
4 The number is formatted according to the locale's international currency format (e.g. for the USA locale: USD 1,234.56).
<?php
echo currency_format(37, 'USD');
?>
5 The number is formatted according to the locale's national currency format (e.g. for the de_DE locale: EU1.234,56).
<?php
echo currency_format(5000000);
?>
7 Returns the
<?php
echo currency_format(5000000);
?>
7 character. The number to be formatted. 37USD
0 and emitting 37USD
1.
Ví dụ
Ví dụ #1 Money_Format () Ví dụmoney_format() Example
Chúng tôi sẽ sử dụng các địa phương và thông số kỹ thuật định dạng khác nhau để minh họa việc sử dụng chức năng này.
37USD
2<?php
/**
*
* Chuyển đổi chuỗi kí tự thành dạng slug dùng cho việc tạo friendly url.
*
* @access public
* @param string
* @return string
*/
if (!function_exists('currency_format')) {
function currency_format($number, $suffix = 'đ') {
if (!empty($number)) {
return number_format($number, 0, ',', '.') . "{$suffix}";
}
}
}
337USD
4Ghi chú
Ghi chú::
Hàm money_format () chỉ được xác định nếu hệ thống có khả năng strfmon. Ví dụ: Windows không, vì vậy Money_Format () không được xác định trong Windows.money_format() is only defined if the system has strfmon capabilities. For example, Windows does not, so money_format() is undefined in Windows.
Ghi chú::
Hàm money_format () chỉ được xác định nếu hệ thống có khả năng strfmon. Ví dụ: Windows không, vì vậy Money_Format () không được xác định trong Windows.37USD
5 category of the locale settings, affects the behavior of this function. Use setlocale() to set to the appropriate default locale before using this function.
Danh mục 37USD5 của cài đặt địa phương, ảnh hưởng đến hành vi của chức năng này. Sử dụng setLocale () để đặt thành locale mặc định thích hợp trước khi sử dụng chức năng này.
- Xem thêm
- setlocale () - Đặt thông tin địa phương
- sscanf () - đầu vào phân tích cú pháp từ một chuỗi theo định dạng
- Sprintf () - Trả về chuỗi được định dạng
- printf () - đầu ra chuỗi được định dạng
number_format () - Định dạng một số với hàng ngàn nhóm ¶
Tim ¶
37USD
637USD
737USD
837USD
97 năm trước currency_format($number[, $suffix = 'đ'])
0 ¶
Todoventas tại Xarxa-Cat Dot Net
currency_format($number[, $suffix = 'đ'])
1currency_format($number[, $suffix = 'đ'])
2currency_format($number[, $suffix = 'đ'])
3currency_format($number[, $suffix = 'đ'])
4currency_format($number[, $suffix = 'đ'])
0 8 năm trước ¶
Rafael M. Salvioni ¶
currency_format($number[, $suffix = 'đ'])
6currency_format($number[, $suffix = 'đ'])
7currency_format($number[, $suffix = 'đ'])
8currency_format($number[, $suffix = 'đ'])
9<?php
/**
*
* Chuyển đổi chuỗi kí tự thành dạng slug dùng cho việc tạo friendly url.
*
* @access public
* @param string
* @return string
*/
if (!function_exists('currency_format')) {
function currency_format($number, $suffix = 'đ') {
if (!empty($number)) {
return number_format($number, 0, ',', '.') . "{$suffix}";
}
}
}
0<?php
/**
*
* Chuyển đổi chuỗi kí tự thành dạng slug dùng cho việc tạo friendly url.
*
* @access public
* @param string
* @return string
*/
if (!function_exists('currency_format')) {
function currency_format($number, $suffix = 'đ') {
if (!empty($number)) {
return number_format($number, 0, ',', '.') . "{$suffix}";
}
}
}
1<?php
/**
*
* Chuyển đổi chuỗi kí tự thành dạng slug dùng cho việc tạo friendly url.
*
* @access public
* @param string
* @return string
*/
if (!function_exists('currency_format')) {
function currency_format($number, $suffix = 'đ') {
if (!empty($number)) {
return number_format($number, 0, ',', '.') . "{$suffix}";
}
}
}
2 13 năm trước ¶
Rafael M. Salvioni ¶
<?php
/**
*
* Chuyển đổi chuỗi kí tự thành dạng slug dùng cho việc tạo friendly url.
*
* @access public
* @param string
* @return string
*/
if (!function_exists('currency_format')) {
function currency_format($number, $suffix = 'đ') {
if (!empty($number)) {
return number_format($number, 0, ',', '.') . "{$suffix}";
}
}
}
3<?php
/**
*
* Chuyển đổi chuỗi kí tự thành dạng slug dùng cho việc tạo friendly url.
*
* @access public
* @param string
* @return string
*/
if (!function_exists('currency_format')) {
function currency_format($number, $suffix = 'đ') {
if (!empty($number)) {
return number_format($number, 0, ',', '.') . "{$suffix}";
}
}
}
4currency_format($number[, $suffix = 'đ'])
0 13 năm trước
¶
Jeremy ¶
<?php
/**
*
* Chuyển đổi chuỗi kí tự thành dạng slug dùng cho việc tạo friendly url.
*
* @access public
* @param string
* @return string
*/
if (!function_exists('currency_format')) {
function currency_format($number, $suffix = 'đ') {
if (!empty($number)) {
return number_format($number, 0, ',', '.') . "{$suffix}";
}
}
}
6 JSB17NO tại spamcornell dot edu ¶ ¶
9 năm trước
<?php
/**
*
* Chuyển đổi chuỗi kí tự thành dạng slug dùng cho việc tạo friendly url.
*
* @access public
* @param string
* @return string
*/
if (!function_exists('currency_format')) {
function currency_format($number, $suffix = 'đ') {
if (!empty($number)) {
return number_format($number, 0, ',', '.') . "{$suffix}";
}
}
}
7<?php
/**
*
* Chuyển đổi chuỗi kí tự thành dạng slug dùng cho việc tạo friendly url.
*
* @access public
* @param string
* @return string
*/
if (!function_exists('currency_format')) {
function currency_format($number, $suffix = 'đ') {
if (!empty($number)) {
return number_format($number, 0, ',', '.') . "{$suffix}";
}
}
}
8<?php
/**
*
* Chuyển đổi chuỗi kí tự thành dạng slug dùng cho việc tạo friendly url.
*
* @access public
* @param string
* @return string
*/
if (!function_exists('currency_format')) {
function currency_format($number, $suffix = 'đ') {
if (!empty($number)) {
return number_format($number, 0, ',', '.') . "{$suffix}";
}
}
}
9currency_format($number[, $suffix = 'đ'])
0 ~ B ¶ ¶
10 năm trước
<?php
echo currency_format(5000000);
?>
1<?php
echo currency_format(5000000);
?>
2<?php
echo currency_format(5000000);
?>
3<?php
echo currency_format(5000000);
?>
4<?php
echo currency_format(5000000);
?>
5<?php
echo currency_format(5000000);
?>
6<?php
echo currency_format(5000000);
?>
7<?php
echo currency_format(5000000);
?>
8currency_format($number[, $suffix = 'đ'])
0 Felix Duterloo ¶ ¶
6 năm trước
5.000.000đ
0andrey.dobrozhanskiy [-a-t-] gmail com ¶
currency_format($number[, $suffix = 'đ'])
0 12 năm trước ¶
5.000.000đ
1
5.000.000đ
35.000.000đ
4currency_format($number[, $suffix = 'đ'])
0 Richard Dot Selby tại Vương quốc Anh Dot Clara Dot Net ¶
16 năm trước
5.000.000đ
65.000.000đ
75.000.000đ
85.000.000đ
9 SWAPNET ¶ ¶
Todoventas tại Xarxa-Cat Dot Net
<?php
/**
*
* Chuyển đổi chuỗi kí tự thành dạng slug dùng cho việc tạo friendly url.
*
* @access public
* @param string
* @return string
*/
if (!function_exists('currency_format')) {
function currency_format($number, $suffix = 'đ') {
if (!empty($number)) {
return number_format($number, 0, ',', '.') . "{$suffix}";
}
}
}
00<?php
/**
*
* Chuyển đổi chuỗi kí tự thành dạng slug dùng cho việc tạo friendly url.
*
* @access public
* @param string
* @return string
*/
if (!function_exists('currency_format')) {
function currency_format($number, $suffix = 'đ') {
if (!empty($number)) {
return number_format($number, 0, ',', '.') . "{$suffix}";
}
}
}
01currency_format($number[, $suffix = 'đ'])
0 8 năm trước ¶
9 năm trước
<?php
/**
*
* Chuyển đổi chuỗi kí tự thành dạng slug dùng cho việc tạo friendly url.
*
* @access public
* @param string
* @return string
*/
if (!function_exists('currency_format')) {
function currency_format($number, $suffix = 'đ') {
if (!empty($number)) {
return number_format($number, 0, ',', '.') . "{$suffix}";
}
}
}
03<?php
/**
*
* Chuyển đổi chuỗi kí tự thành dạng slug dùng cho việc tạo friendly url.
*
* @access public
* @param string
* @return string
*/
if (!function_exists('currency_format')) {
function currency_format($number, $suffix = 'đ') {
if (!empty($number)) {
return number_format($number, 0, ',', '.') . "{$suffix}";
}
}
}
04<?php
/**
*
* Chuyển đổi chuỗi kí tự thành dạng slug dùng cho việc tạo friendly url.
*
* @access public
* @param string
* @return string
*/
if (!function_exists('currency_format')) {
function currency_format($number, $suffix = 'đ') {
if (!empty($number)) {
return number_format($number, 0, ',', '.') . "{$suffix}";
}
}
}
05<?php
/**
*
* Chuyển đổi chuỗi kí tự thành dạng slug dùng cho việc tạo friendly url.
*
* @access public
* @param string
* @return string
*/
if (!function_exists('currency_format')) {
function currency_format($number, $suffix = 'đ') {
if (!empty($number)) {
return number_format($number, 0, ',', '.') . "{$suffix}";
}
}
}
06<?php
/**
*
* Chuyển đổi chuỗi kí tự thành dạng slug dùng cho việc tạo friendly url.
*
* @access public
* @param string
* @return string
*/
if (!function_exists('currency_format')) {
function currency_format($number, $suffix = 'đ') {
if (!empty($number)) {
return number_format($number, 0, ',', '.') . "{$suffix}";
}
}
}
07<?php
/**
*
* Chuyển đổi chuỗi kí tự thành dạng slug dùng cho việc tạo friendly url.
*
* @access public
* @param string
* @return string
*/
if (!function_exists('currency_format')) {
function currency_format($number, $suffix = 'đ') {
if (!empty($number)) {
return number_format($number, 0, ',', '.') . "{$suffix}";
}
}
}
08 ~ B ¶ ¶
16 năm trước
<?php
/**
*
* Chuyển đổi chuỗi kí tự thành dạng slug dùng cho việc tạo friendly url.
*
* @access public
* @param string
* @return string
*/
if (!function_exists('currency_format')) {
function currency_format($number, $suffix = 'đ') {
if (!empty($number)) {
return number_format($number, 0, ',', '.') . "{$suffix}";
}
}
}
09<?php
/**
*
* Chuyển đổi chuỗi kí tự thành dạng slug dùng cho việc tạo friendly url.
*
* @access public
* @param string
* @return string
*/
if (!function_exists('currency_format')) {
function currency_format($number, $suffix = 'đ') {
if (!empty($number)) {
return number_format($number, 0, ',', '.') . "{$suffix}";
}
}
}
10<?php
/**
*
* Chuyển đổi chuỗi kí tự thành dạng slug dùng cho việc tạo friendly url.
*
* @access public
* @param string
* @return string
*/
if (!function_exists('currency_format')) {
function currency_format($number, $suffix = 'đ') {
if (!empty($number)) {
return number_format($number, 0, ',', '.') . "{$suffix}";
}
}
}
11<?php
/**
*
* Chuyển đổi chuỗi kí tự thành dạng slug dùng cho việc tạo friendly url.
*
* @access public
* @param string
* @return string
*/
if (!function_exists('currency_format')) {
function currency_format($number, $suffix = 'đ') {
if (!empty($number)) {
return number_format($number, 0, ',', '.') . "{$suffix}";
}
}
}
12<?php
/**
*
* Chuyển đổi chuỗi kí tự thành dạng slug dùng cho việc tạo friendly url.
*
* @access public
* @param string
* @return string
*/
if (!function_exists('currency_format')) {
function currency_format($number, $suffix = 'đ') {
if (!empty($number)) {
return number_format($number, 0, ',', '.') . "{$suffix}";
}
}
}
13<?php
/**
*
* Chuyển đổi chuỗi kí tự thành dạng slug dùng cho việc tạo friendly url.
*
* @access public
* @param string
* @return string
*/
if (!function_exists('currency_format')) {
function currency_format($number, $suffix = 'đ') {
if (!empty($number)) {
return number_format($number, 0, ',', '.') . "{$suffix}";
}
}
}
14 SWAPNET ¶ ¶
14 năm trước
<?php
/**
*
* Chuyển đổi chuỗi kí tự thành dạng slug dùng cho việc tạo friendly url.
*
* @access public
* @param string
* @return string
*/
if (!function_exists('currency_format')) {
function currency_format($number, $suffix = 'đ') {
if (!empty($number)) {
return number_format($number, 0, ',', '.') . "{$suffix}";
}
}
}
15 Kaigillmann tại googlemail dot com ¶ ¶
PHPDeveloperBalaji tại Gmail Dot Com ¶
<?php
/**
*
* Chuyển đổi chuỗi kí tự thành dạng slug dùng cho việc tạo friendly url.
*
* @access public
* @param string
* @return string
*/
if (!function_exists('currency_format')) {
function currency_format($number, $suffix = 'đ') {
if (!empty($number)) {
return number_format($number, 0, ',', '.') . "{$suffix}";
}
}
}
16<?php
/**
*
* Chuyển đổi chuỗi kí tự thành dạng slug dùng cho việc tạo friendly url.
*
* @access public
* @param string
* @return string
*/
if (!function_exists('currency_format')) {
function currency_format($number, $suffix = 'đ') {
if (!empty($number)) {
return number_format($number, 0, ',', '.') . "{$suffix}";
}
}
}
17<?php
/**
*
* Chuyển đổi chuỗi kí tự thành dạng slug dùng cho việc tạo friendly url.
*
* @access public
* @param string
* @return string
*/
if (!function_exists('currency_format')) {
function currency_format($number, $suffix = 'đ') {
if (!empty($number)) {
return number_format($number, 0, ',', '.') . "{$suffix}";
}
}
}
18Scot từ ezyauctionz.co.nz ¶