Get the sum of digits in PHP

后端 未结 13 2771
攒了一身酷
攒了一身酷 2020-11-29 10:45

How do I find the sum of all the digits in a number in PHP?

13条回答
  •  Happy的楠姐
    2020-11-29 11:41

    Assume you want to find the sum of the digits of a number say 2395 the simplest solution would be to first split the digits and find out the sum then concatenate all the numbers into one single number.

    
    

提交回复
热议问题