String Case conversion
<?php
function string_inverse_string($str)
{
//Make everything uppercase, and then compare
$new = strtoupper( $str );
//split into arrays
$s = str_split( $str );
$n = str_split( $new );
//now we step through each letter, and if its the same as before, we swap it out
for ($i = 0; $i < count($s); $i++)
{
//If the letters are identical, then it was already uppercase, so make it lowercase
if ( $s[$i] === $n[$i] ) { $n[$i] = strtolower($n[$i]); }
}
//join the new string back together
$newstr = implode(”", $n);
return $newstr;
}
$input = “This Is Test String”;
$inv = string_inverse_string($input);
?>
The above String_inverse_case() funtion is used to convert the lower case letters into upper case and upper case letters into lower case letters.
