Speed up development with full-stack environments for every branch.

Learn More

Check if a string contains only alphabetic lowercase characters with ctype_lower

23 Runs 435 Views 46 Copies


gtsolutions 373

published 4 years ago


 * Example for ctype_lower() function usage  
 * checks if a string contains only lowercase alphabetic characters
//$exampleStrings is an array with different strings that needs to be tested
echo '<!DOCTYPE html>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
$exampleStrings = array('pingponG', 'ferrari', 'ret233');
foreach ($exampleStrings as $string) {
    if (ctype_lower($string)) {
        //if the $string contains only lowercase alphabetic charcaters display the message bellow
        echo '<br /><div style="background-color:green;color:#fff;padding:10px;width:400px;font-size:16px">
        The string <b>' . $string . '</b> consists of all lowercase alphabetic characters</div><br />';
    } else {
        //if the $string does not contains only control charcaters display the message bellow
        echo '<br /><div style="background-color:red;color:#fff;padding:10px;width:400px;font-size:16px">
        The string <b>' . $string . '</b> does not consist of all lowercase alphabetic characters
        </div><br />';
echo '</center>
Please login/signup to get access to the terminal.

Your session has timed out.

Dismiss (the page may not function properly).