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 secretCode($text, $shift) {
$result = '';
for ($i = 0; $i < strlen($text); $i++) {
$char = $text[$i];
if (ctype_alpha($char)) {
$shifted = ord($char) + $shift;
if (ctype_upper($char)) {
$result .= chr((($shifted - 65) % 26) + 65);
} else {
$result .= chr((($shifted - 97) % 26) + 97);
}
} else {
$result .= $char;
}
}
return $result;
}
echo secretCode('AZ', 3);