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.
<?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"; } } ?> |
Output :
No Yes No
Recommended Posts:
- How to check a string begins with some given characters/pattern ?
- How to use a switch case 'or' in PHP?
- Case insensitive search in JavaScript
- How to convert string to camel case in JavaScript ?
- How to convert hyphens to camel case in JavaScript ?
- Compare the Case Insensitive strings in JavaScript
- PHP | Different characters in the given string
- How to get the last n characters of a PHP string?
- JavaScript to keep only first N characters in a string
- How to remove non-alphanumeric characters in PHP?
- How to remove all non-printable characters in a string in PHP?
- Which characters are valid in CSS class names/selectors?
- JavaScript | Strip all non-numeric characters from string
- Replace special characters in a string with underscore (_) in JavaScript
- PHP | check if a number is Even or Odd
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.



