PHP | Check if all characters are lower case

Given a string, check if all characters of it are in lowercase.

Examples:

Input  : gfg123
Output : No
Explanation : There are characters
'1', '2' and '3' that are not lower-
case

Input  : geeksforgeeks
Output : Yes
Explanation : The string "geeksforgeeks" 
consists of all lowercase letters.

The above problem can be solved using the in-built functions in PHP. We store multiple values in an array and check using the in-built function in php to chech whether all the characters are lowercase.

We solve the given problem using the in-built functions in PHP and iterate from a given array of strings.We use the following in-built function in PHP:

  • ctype_lower : Returns true if all of the characters in the provided string, text, are lowercase letters. Otherwise returns false.
filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
// PHP program to check if a string has all
// lower case characters
  
$strings = array('gfg123', 'geeksforgeeks', 'GfG');
  
// Checking for above three strings one by one.
foreach ($strings as $testcase) {
    if (ctype_lower($testcase)) {
        echo "Yes\n";
    } else {
        echo "No\n";
    }
}
?>

chevron_right


Output :

No
Yes
No


My Personal Notes arrow_drop_up

Work hard till success becomes easier to achieve

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.