php에서 숫자 자리 수 세기. 내 취향은 아님.
function digit_count($n, $base=10) {
if($n == 0) return 1;
if($base == 10) {
# using the built-in log10(x)
# might be more accurate than log(x)/log(10).
return 1 + floor(log10(abs($n)));
}else{
# here logB(x) = log(x)/log(B) will have to do.
return 1 + floor(log(abs($n))/ log($base));
}
}
