simplest, shortest way to count capital letters in a string with php?

Viewed 13614

I am looking for the shortest, simplest and most elegant way to count the number of capital letters in a given string.

5 Answers
$str = "AbCdE";

preg_match_all("/[A-Z]/", $str); // 3
Related