![]() |
How to count Integer lenght
Hi,
How can i count an Integer lenght? Example: $X= 8766435322364576; Also dif. between strval($X) V.S. (string)($X)? Regards. |
You can use strlen.
The only difference is speed there. (string) is an explicit cast (aka a language construct), whereas strval is a function, and therefore, is more memory consuming. |
Xenon: You can use strlen.
No i can't use that. This is for String, not Integer. StringLength no IntegerLength! Test this: $X= 8766435322364545664565464654676; echo(strlen($X)); |
I found.
Finded: function _Number_Length($Int_Input) { $_Int_Output= number_format($Int_Input, 0, '.', ''); return((integer)strlen($_Int_Output)); } Resolved. |
Ok then, just convert the int to a string before passing it to strlen. Aka:
PHP Code:
|
Quote:
|
Try:
echo strlen((string) 12345678901234567890); |
Quote:
|
| All times are GMT. The time now is 10:17 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0