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