array_sum(str_split($number));
This assumes the number is positive (or, more accurately, that the conversion of $number
into a string generates only digits).
More Related Contents:
- How do I check if a string contains a specific word?
- Split a comma-delimited string into an array?
- How to sum all column values in multi-dimensional array?
- startsWith() and endsWith() functions in PHP
- Why does PHP consider 0 to be equal to a string?
- Replacing accented characters php
- How to remove accents and turn letters into “plain” ASCII characters? [duplicate]
- Convert a comma-delimited string into array of integers?
- How to get everything after a certain character?
- Get first 100 characters from string, respecting full words
- PHP remove special character from string
- Iterate over each line in a string in PHP
- Generate SEO friendly URLs (slugs) [closed]
- PHP: How can I explode a string by commas, but not wheres the commas are within quotes?
- How to get int instead string from form?
- Print newline in PHP in single quotes
- PHP: How to sort the characters in a string?
- Multi-line strings in PHP
- Why does PHP convert a string with the letter E into a number?
- sum specific values in a multidimensional array (php)
- Check if URL has certain string with PHP
- PHP: Split string into array, like explode with no delimiter
- How to open file in PHP that has unicode characters in its name?
- how to extract links and titles from a .html page?
- Remove Trailing Slash From String PHP
- Measure string size in Bytes in php
- Explode a paragraph into sentences in PHP
- How do I get the byte values of a string in PHP?
- Regex to match an IP address [closed]
- How do I detect non-ASCII characters in a string?