PHP uppercase letter in String

PHP uppercase letter in String

Like the title says, I'm trying to find the simplest way to test if a string contains an uppercase letter in it. it's for a password field, and that i cannot use regex because we've not learned any of that yet in school.

I tried to use ctype_upper but that only seems to figure if every character within the string is uppercase.

Is there the simplest way to test any character during a string, but not using regex?

Solution :
(PHP 4, PHP 5, PHP 7)
strtoupper - Returns a string in uppercase
strtoupper (string $ string): string
strtoupper () returns string, after converting all alphabetic characters to uppercase.
Note that the notion of "alphabetic" is determined by the location configuration. This means that for the default configuration "C", characters such as accented vowels (like é, è or à) will not be converted.
if (strtoupper($string) == $string) {
echo $string.' is all uppercase letters.';}
if you want to improve the solution,
comment with your solution to help the community

No comments
Post a Comment

Post a Comment