Q:

Write a PHP function that checks whether a string is all lower case

0

Write a PHP function that checks whether a string is all lower case

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

<?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)

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now