PHP - Get length of digits in a number

supersize picture supersize · Feb 10, 2015 · Viewed 60.5k times · Source

I would like to ask how I can get the length of digits in an Integer. For example:

$num = 245354;
$numlength = mb_strlen($num);

$numlength should be 6 in this example. Somehow I can't manage it to work?

Thanks

EDIT: The example code above --^ and its respective method mb_strlen(); works just fine.

Answer

Sergei Gorjunov picture Sergei Gorjunov · Feb 10, 2015

Maybe:

$num = 245354;
$numlength = strlen((string)$num);