Re: Thousands Separator

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jeffry Killen wrote:

> Sorry, there is a misunderstanding on my part here:
> On Jan 16, 2015, at 2:31 PM, Jeffry Killen wrote:
> 
>> Here is some more that you may find useful:
>>
>> In your hypothetical example:
>> $num = '123_456_789',
>> $num is a string.
>> and I presume you mean that this is hard coded into your source file
>> code and you want to be able to read the source code with greater ease.
>> So you can hard code it this way and if you want to use the value as an
>> actual number in some mathmatical processing:
>>
> settype does not return anything accept true or false.

One could use intval()/floatval() or an (int)/(float) cast instead.

>> settype(str_replace('_', '', '123_456_789'), 'int');
>>
>> or--
>> $num = '123_456_789';
>> function use($num)
>>    {
>>      settype(str_replace('_', '', $num), 'int')
>>   }
>> $num = use($num);
>>
>> Or settype( string, 'float') if there is a decimal fraction involved.

-- 
Christoph M. Becker


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux