Skip to content
Related Articles

Related Articles

PHP | Check if all characters are lower case
  • Difficulty Level : Easy
  • Last Updated : 15 Mar, 2018
GeeksforGeeks - Summer Carnival Banner

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


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

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.

// 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";

Output :


Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :