PHP Exercise and solutions: Displaying string lowercase – codzhub

Displaying string lowercase

Sample Solution:

PHP Code:

<?php
function is_str_lowercase($str1)
   {
    for ($sc = 0; $sc < strlen($str1); $sc++) {
	      if (ord($str1[$sc]) >= ord('A') &&
          ord($str1[$sc]) <= ord('Z')) {
      return false;
         }
         }
      return true;
       }
var_dump(is_str_lowercase('abc def ghi'));
var_dump(is_str_lowercase('abc dEf ghi'));
?>

Sample Output:

bool(true)                                                  
bool(false)

Leave a Reply

Your email address will not be published. Required fields are marked *