PHP - Get length of digits in a number

前端 未结 10 1397
长发绾君心
长发绾君心 2021-01-01 12:40

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

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

$numl

10条回答
  •  不知归路
    2021-01-01 13:13

    count only integer value

      `";
            $count = 0; 
            while ($n1 != 0)  
            { 
                $n1 = $n1 / 10;
                $n1 = intval($n1);
                ++$count; 
            } 
            echo "The Digit in a Number: ".$count;
        }
        ?>`
    

提交回复
热议问题