phpnumbersstring-length

PHP - Get length of digits in a number


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.


Solution

  • Maybe:

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