Created
January 31, 2017 15:43
-
-
Save vdonchev/dcc9ae1a7d2146f08d0c0031923e8aab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$str = strtolower(trim(fgets(STDIN))); | |
for ($i = 0; $i < strlen($str); $i++) { | |
if (ctype_alpha($str[$i])) { | |
$pos = letterPosition($str[$i]); | |
echo "{$str[$i]} -> {$pos}\n"; | |
} | |
} | |
function letterPosition($letter) | |
{ | |
return ord($letter) - 97; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment