Currently, I am using a foreach() loop to count the occurrences of numbers in a string...and to count uppercase letters...and to count lowercase letter...and to count special chars. I feel like there is a "simpler" to do it with regex. Is there?
-Geates
Code:
$n = 0;
$string_as_array = str_split("12sCdf@5sd78%");
foreach($string_as_array as $char) {
if (is_numeric($char)) {
$n += 1;
}
}
-Geates