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 = '';
for ($i = 0; $i < mb_strlen($text); $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('Мама мыла раму');