forked from mouredev/retos-programacion-2023
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
55 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
declare (strict_types = 1); | ||
|
||
/** | ||
* The `aurebesh` function translates a given string into a fictional language called Aurebesh, using a | ||
* predefined mapping of letters. | ||
* | ||
* @param string txt The `txt` parameter is a string that represents the text that needs to be | ||
* translated into Aurebesh. | ||
* | ||
* @return string a string that has been translated from English to Aurebesh. | ||
*/ | ||
function aurebesh(string $txt): string | ||
{ | ||
$translated = []; | ||
$letters = [ | ||
'a' => 'aur', | ||
'b' => 'besh', | ||
'c' => 'cresh', | ||
'd' => 'dorn', | ||
'e' => 'esh', | ||
'f' => 'forn', | ||
'g' => 'gol', | ||
'h' => 'herf', | ||
'i' => 'is', | ||
'j' => 'jenth', | ||
'k' => 'kran', | ||
'l' => 'lor', | ||
'm' => 'mar', | ||
'n' => 'nal', | ||
'o' => 'oth', | ||
'p' => 'pal', | ||
'q' => 'quen', | ||
'r' => 'res', | ||
's' => 'sin', | ||
't' => 'tor', | ||
'u' => 'ul', | ||
'v' => 'ver', | ||
'w' => 'wor', | ||
'x' => 'xesh', | ||
'y' => 'yen', | ||
'z' => 'zorn', | ||
]; | ||
|
||
$txt = str_split(mb_strtolower($txt)); | ||
|
||
foreach ($txt as $value) { | ||
array_push($trans, $letters[$value] ?? $value); | ||
} | ||
|
||
return implode('', $trans); | ||
} | ||
|
||
echo aurebesh('hello there'); |