PHP Check if all characters are lowercase

PHP

Examples:
Input: gfg123 Output: No Explanation: There are characters '1',' 2' and '3' that are not lower- case Input: engineerforengineer Output: Yes Explanation: The string "engineerforengineer" consists of all lowercase letters. 
The above problem can be solved with built-in functions in PHP. We store multiple values ​​in an array and check using a built-in function in php to check if all characters are lowercase. We solve this problem with built-in functions in PHP and iterate from a given array of strings. We use the following built-in PHP function:
  • ctype_lower : returns true if all characters in the provided string text are lowercase. Returns false otherwise.

// PHP program to check if there are all in a line
// lowercase letters $strings = array ( 'gfg123' , ' engineerforengineer' , 'GfG' );  
// Check more than three lines one after the other. foreach ( $strings as $testcase ) { if (ctype_lower ( $testcase )) { echo "Yes" ; } else { echo "No" ; } }
?>
Exit:
No Yes No 




Get Solution for free from DataCamp guru