Hey,
How could I add all of the digits of a number together through a function (e.g., 408 would become 4+0+8 = 12, so the output of the function would be 12)? I've never had to do anything like that before in PHP...
Thanks for the help!!
Tipem![]()
| SitePoint Sponsor |
Hey,
How could I add all of the digits of a number together through a function (e.g., 408 would become 4+0+8 = 12, so the output of the function would be 12)? I've never had to do anything like that before in PHP...
Thanks for the help!!
Tipem![]()
array_sum(str_split(number))
Thanks! It works great!![]()
Bookmarks