Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

the answer to this could be easy. But I'm very fresh to programming. So be gentle...

I'm at work trying to do a quick fix for one of your customers. I want to get the total numbers of digits in a integer, and then explode the integer:

rx_freq = 1331000000 ( = 10 )
  $array[0] = 1
  $array[1] = 3
  .
  .
  $array[9] = 0

rx_freq = 990909099 ( = 9 )
  $array[0] = 9
  $array[1] = 9
  .
  .
  $array[8] = 9

I'm not able to use explode, as this function need a delimiter. I've searched the eyh'old Google and Stackoverflow.

Basically: How do I explode an integer without delimiter, and how do I find the number of digits in an integer.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
299 views
Welcome To Ask or Share your Answers For Others

1 Answer

$array = str_split($int) and $num_digits = strlen($int) should work just fine.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...