Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
436 B
5
Indexable
Never
<?php
$strResource = 'abcdefghijklmnopqrstuvwxyz';
$str = "CharzE";
$strAnswer = '';
$strLow = strtolower($str);
for ($i = 0; $i < strlen($str); $i++) {
    $counter = substr_count($strLow, strtolower($str[$i]));
    $temp = ($counter * stripos($strResource, $str[$i]) + 1) % 26;
    if (ctype_upper($str[$i]))
        $strAnswer .= strtoupper($strResource[$temp]);
    else
        $strAnswer .= $strResource[$temp];
}
echo $strAnswer;