What is the best way to see if a string contains mostly capital letters?
The string may also contain symbols, spaces, numbers, so would still want it to return true in those cases.
For example: I can check if a strings is ALL-CAPS by something similar to this:
if (strtoupper($str) == $str) { /* its true */ }
But what if we need to determine if a string is 80% or more ALL-CAPs.
THE 15 SMALL BROWN FOXES JUMP INTO THE BURNING barn! -> true
The 15 Small Brown Foxes JUMP Into the Burning Barn! -> false
I can loop though all the characters, checking them individually, but thats seems a bit wasteful imho.
Is there a better way?