Skip to content

Commit

Permalink
Reto mouredev#15 - php
Browse files Browse the repository at this point in the history
Reto mouredev#15 fue resuelto en php.
  • Loading branch information
kodenook-dev committed Sep 8, 2023
1 parent 7c69674 commit 8740f17
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions Retos/Reto #15 - AUREBESH [Fácil]/php/kodenook.php
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');

0 comments on commit 8740f17

Please sign in to comment.