Hi! Could we please enable some services and cookies to improve your experience and our website?
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
<?php
function invertCase($text)
{
// BEGIN (write your solution here)
$result = '';
$toUpper = '';
$l = mb_strlen($text);
for ($i = 0; $i < $l; $i++) {
$char = mb_substr($text, $i, 1);
$toUpper = mb_strtoupper($char);
if ($toUpper === $char) {
$result .= mb_strtolower($char);
} else {
$result .= mb_strtoupper($char);
}
}
return $result;
// END
}
echo invertCase('Мама мыла раму');