1
0
This commit is contained in:
Christer Warén 2022-06-17 12:51:00 +03:00
commit c42f9e4109
3 changed files with 68 additions and 0 deletions

8
characters.json Normal file
View File

@ -0,0 +1,8 @@
{
"A": "4",
"E": "3",
"I": "1",
"O": "0",
"S": "5",
"T": "7"
}

59
index.php Normal file
View File

@ -0,0 +1,59 @@
<?php
$characters = file_get_contents(__DIR__."/characters.json");
$characters = json_decode($characters);
echo "
=============== WiseText Generator ===============
";
echo "\n\n";
$stdin = fopen('php://stdin', 'r');
echo "Select Mode: "."\n";
echo "1: Normal Text to Wise Text "."\n";
echo "2: Wise Text to Normal Text "."\n";
$input = trim(fgets($stdin));
echo "\n"."\n";
if(isset($input) && $input != '' && $input == '1'){
echo "Insert text: "."\n";
$input = trim(fgets($stdin));
if(isset($input) && $input != ''){
$input = mb_strtoupper($input);
foreach($characters as $key => $value){
$input = str_replace($key, $value, $input);
}
echo "\n"."\n";
echo "Answer: "."\n";
echo "$input"."\n"."\n";
}
}
if(isset($input) && $input != '' && $input == '2'){
echo "Insert text: "."\n";
$input = trim(fgets($stdin));
if(isset($input) && $input != ''){
$input = mb_strtoupper($input);
foreach($characters as $key => $value){
$input = str_replace($value, $key, $input);
}
echo "\n"."\n";
echo "Answer: "."\n";
echo "$input"."\n"."\n";
}
}
?>

1
run.sh Normal file
View File

@ -0,0 +1 @@
docker run -it --rm --name php -v "$PWD":/usr/src/myapp -w /usr/src/myapp php:7-cli php index.php