I was looking for a quick PHP function that, given a string, would count the number of numerical characters (i.e. digits) in that string. I couldn\'t find one, is there a fu
This function goes through the given string and checks each character to see if it is numeric. If it is, it increments the number of digits, then returns it at the end.
function countDigits($str) {
$noDigits=0;
for ($i=0;$i