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

php numberformatter currency without symbol

// change symbol to whatever you want, nothing to no-symbol
$fmt = new NumberFormatter('en_GB',  NumberFormatter::CURRENCY);
$fmt->setSymbol(NumberFormatter::CURRENCY_SYMBOL, '');
echo $fmt->formatCurrency($price, 'EUR');
Comment

php currency formator

$number = 100000;
echo number_format($number);
// 100,000
Comment

display money format php

<?php 


	$number = 1234.56;

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

	

 ?>
Comment

PREVIOUS NEXT
Code Example
Php :: laravel-medialibrary change name of file 
Php :: how to bulk insert array into sql php 
Php :: how to delete php from win10 
Php :: get value from json laravel 
Php :: parameterized function in php 
Php :: laravel get all users except role spatie 
Php :: add log in laravel 8 
Php :: json_decode object to array 
Php :: flutter network image svg 
Php :: php empty object 
Php :: php remove anchor tag from string 
Php :: php convert object to array nested 
Php :: php float round 
Php :: how to redirect to another page in php 
Php :: laravel collection search by value 
Php :: --prefer-dist what is use in laravel 
Php :: log data into file php 
Php :: php test page 
Php :: laravel asset 
Php :: how to run specific migration in laravel 
Php :: Undefined index: id 
Php :: how to prompt user for input in php 
Php :: add two numbers as string in php 
Php :: php iterate thru object 
Php :: laravel collection find duplicates 
Php :: do while php 
Php :: How to use my constants in Larvel 
Php :: define constant in php 
Php :: laravel unique column except self 
Php :: convert single quote in htmlentities php 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =