Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get number without thousand separator?

Tags:

php

I have number ie 1,15,200 I want change to 115200 because when I divide it, it just divide 1 (before first comma)

eg : 1,15,200 / 100

output : 0.01

suppose to output : 1152

like image 297
Aryan G Avatar asked Sep 18 '11 02:09

Aryan G


People also ask

Do not use thousands separators?

Don't put thousands-separators in the characters on the right of the decimal point. The groups of digits separated by the thousands separator must all be the same size (usually groups of three digits). It is OK if the first group has fewer digits.

How do I change the separator in numbers?

Click File > Options. On the Advanced tab, under Editing options, clear the Use system separators check box. Type new separators in the Decimal separator and Thousands separator boxes. Tip: When you want to use the system separators again, select the Use system separators check box.

Should I use comma or dot in numbers?

Great Britain and the United States are two of the few places in the world that use a period to indicate the decimal place. Many other countries use a comma instead. The decimal separator is also called the radix character.

How do you add 1000 separators in Word?

Place the cursor at the location you want to insert the 1000 separator, click Insert > Symbol > More Symbols. 2. In the Symbol dialog, under Symbols tab select Verdana from Font drop-down list, then select Basic Latin from Subset drop-down list, now select the 1000 separator from the list, click Insert to insert it.


3 Answers

$num = (int)str_replace(',', '', $string);
// or
$num = (int)preg_replace('/[^\d]/', '', $string);
like image 152
drew010 Avatar answered Sep 20 '22 14:09

drew010


Try this way:

$num = filter_var('1,15,200', FILTER_SANITIZE_NUMBER_INT);
like image 36
Oleksiy Stepaniuk Avatar answered Sep 16 '22 14:09

Oleksiy Stepaniuk


English notation without thousands separator

$english_format_number = number_format($number, 2, '.', '');
like image 27
Ron B Avatar answered Sep 18 '22 14:09

Ron B