views:

44

answers:

4

Hello ... There are number '2352362361 ', as it is separated by spaces from the end of 3 characters? The output should obtain '2 352 362 361 '

+1  A: 

number_format($num, 0, '.', ' ');

djc
+1  A: 

Try number_format

code-zoop
+1  A: 
number_format('2352362361',0,'',' ')

note that argument 3 is empty, where argument 4 is a space

GSto
+2  A: 

If you have that number as a string :

$str = '2352362361 ';

You can first convert that string to an integer, using intval :

$int = intval($str);

And, then, use number_format on that integer :

echo number_format($int, 0, '.', ' ');

And you get :

2 352 362 361

(If the space at the end was intentional, you can add it back if necessary)


And number_format will also work even if you pass it the string without converting it to an integer first :

$str = '2352362361 ';
echo number_format($str, 0, '.', ' ');
Pascal MARTIN