Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php money_format currency symbol


<?php

$number = 1234.56;

// let's print the international format for the en_US locale
setlocale(LC_MONETARY, 'en_US');
echo money_format('%i', $number) . "
";
// USD 1,234.56

// Italian national format with 2 decimals`
setlocale(LC_MONETARY, 'it_IT');
echo money_format('%.2n', $number) . "
";
// Eu 1.234,56

// Using a negative number
$number = -1234.5672;

// US national format, using () for negative numbers
// and 10 digits for left precision
setlocale(LC_MONETARY, 'en_US');
echo money_format('%(#10n', $number) . "
";
// ($        1,234.57)

// Similar format as above, adding the use of 2 digits of right
// precision and '*' as a fill character
echo money_format('%=*(#10.2n', $number) . "
";
// ($********1,234.57)

// Let's justify to the left, with 14 positions of width, 8 digits of
// left precision, 2 of right precision, without the grouping character
// and using the international format for the de_DE locale.
setlocale(LC_MONETARY, 'de_DE');
echo money_format('%=*^-14#8.2i', 1234.56) . "
";
// Eu 1234,56****

// Let's add some blurb before and after the conversion specification
setlocale(LC_MONETARY, 'en_GB');
$fmt = 'The final value is %i (after a 10%% discount)';
echo money_format($fmt, 1234.56) . "
";
// The final value is  GBP 1,234.56 (after a 10% discount)

?>

Comment

PHP money_format — Formats a number as a currency string

<?php

$number = 1234.56;

// let's print the international format for the en_US locale
setlocale(LC_MONETARY, 'en_US');
echo money_format('%i', $number) . "
";
// USD 1,234.56

// Italian national format with 2 decimals`
setlocale(LC_MONETARY, 'it_IT');
echo money_format('%.2n', $number) . "
";
// Eu 1.234,56

// Using a negative number
$number = -1234.5672;

// US national format, using () for negative numbers
// and 10 digits for left precision
setlocale(LC_MONETARY, 'en_US');
echo money_format('%(#10n', $number) . "
";
// ($        1,234.57)

// Similar format as above, adding the use of 2 digits of right
// precision and '*' as a fill character
echo money_format('%=*(#10.2n', $number) . "
";
// ($********1,234.57)

// Let's justify to the left, with 14 positions of width, 8 digits of
// left precision, 2 of right precision, without the grouping character
// and using the international format for the de_DE locale.
setlocale(LC_MONETARY, 'de_DE');
echo money_format('%=*^-14#8.2i', 1234.56) . "
";
// Eu 1234,56****

// Let's add some blurb before and after the conversion specification
setlocale(LC_MONETARY, 'en_GB');
$fmt = 'The final value is %i (after a 10%% discount)';
echo money_format($fmt, 1234.56) . "
";
// The final value is  GBP 1,234.56 (after a 10% discount)

?>
Comment

display money format php

<?php 


	$number = 1234.56;

	echo number_format($number, 2);

	

 ?>
Comment

display money format php

<?php 


	$number = 1234.56;

	echo number_format($number, 2);//without currency

	

 ?>
Comment

PREVIOUS NEXT
Code Example
Php :: install php 5.6 on ubuntu 18.04 
Php :: php combine arrays 
Php :: how to display image in wordpress 
Php :: php check if headers already sent 
Php :: install php-8 
Php :: how to search by sku woocommerce 
Php :: display custom post type 
Php :: laravel disable csrf token 
Php :: laravel log could not be opened fix 
Php :: start someones laravel project 
Php :: cloudflare country 
Php :: php days in month 
Php :: regex php password 
Php :: php array filter only null 
Php :: php select option 
Php :: laravel 8 validation required if another field is not null 
Php :: public_path laravel 
Php :: phpexcel set data type string 
Php :: array_fill php 
Php :: laravel task scheduling command 
Php :: laravel 8: bootstrap 
Php :: php.ini location 
Php :: javascript date to php date 
Php :: php not recognized 
Php :: laravel log build custom channel 
Php :: php erase element from array 
Php :: php variable in string 
Php :: convert any phone number in us number format php 
Php :: how to get last id in database 
Php :: laravel default authentication redirectTo 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =