Introduction
In this article I explain how to check all the character cases in a string using PHP. For checking a character's case in a string I will use two important PHP string functions. This is a very simple technique for checking string cases.
Syntax
This function is basically used for determining if a character is upper case.
|
ctype_upper($text); |
| Parameter | Description |
| text | To required testing string. |
Example
This function returns true when your input character is upper case otherwise it returns false.
<?php
//This syntax value return true
ctype_upper('HELLO')
//This syntax value return false
ctype_upper('hello')
?>
<?php
$str = array('MCNsolution', 'CHARACTER');
foreach ($str as $char)
{
if (ctype_upper($char))
{
echo "$char consists of all uppercase letters.<br>";
} else
{
echo "$char does not have all uppercase letters.<br>";



Join the conversation! Your thoughts help the community grow.