. * * To disable strict typing, comment out the directive below. */ declare(strict_types=1); /** * strrev() does not support multibyte inputs, so we need to use multibyte-aware functions. */ function reverseString(string $text): string { $max = mb_strlen($text); $res = ""; for ($i = 0; $i < $max; $i++) { $res .= mb_substr($text, $max-$i-1, 1); } return $res; }