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 encryptLettersToNumbers($input) {
$output = '';
$input = strtolower($input);
for ($i = 0; $i < strlen($input); $i++) {
$char = $input[$i];
if (ctype_alpha($char)) {
$number = ord($char) - ord('a') + 1;
$output .= $number . ' ';
} else {
$output .= $char;
}
}
return trim($output);
}
$input = "dimooooooooooooooooooooooooooon";
$encrypted = encryptLettersToNumbers($input);
echo $encrypted;