How to use ctype_upper() to checks if all of the characters in a string are uppercase characters in PHP

1 Answer

0 votes
$str = array("ABC123", 'ABC', 'XYz');
foreach ($str as $s) 
{
    if (ctype_upper($s)) 
        echo "string: $s - include only uppercase characters <br />";
    else 
        echo "string: $s - NOT include only uppercase characters <br />";
}


/*
run: 

string: ABC123 - NOT include only uppercase characters
string: ABC - include only uppercase characters
string: XYz - NOT include only uppercase characters  

*/

 



answered Jun 7, 2016 by avibootz
...