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. 回答1: Maybe: $num = 245354; $numlength = strlen((string)$num); 回答2: Accepted answer won't work with the big numbers. The better way to calculate the length of any number is to invoke floor(log10($num