-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackend.php
54 lines (42 loc) · 1.38 KB
/
backend.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
if (filter_has_var(INPUT_POST, "button")) { //check if form was submitted
$sk = filter_input(INPUT_POST, 'sk'); //get input text
$words_arr = explode(" ", $sk);
$out = array();
if(count($words_arr) == 1){
$words_arr = explode(" ", "Moc kratky text brasko");
}
foreach($words_arr as $word){
if(strlen($word) < 3){
array_push($out, $word);
continue;
}
if($word == 'som'){
array_push($out, $word);
continue;
}
$l = $word[-1];
if($l == 'b' || $l == 'c' || $l == 'd' || $l == 'f' || $l == 'g' || $l == 'h' || $l == 'j' || $l == 'k' || $l == 'l' || $l == 'm' || $l == 'n' || $l == 'p' || $l == 'q' || $l == 'r' || $l == 's' || $l == 't' || $l == 'v' || $l == 'w' || $l == 'x' || $l == 'z'){
$word = $word . 'os';
array_push($out, $word);
continue;
}else if($l == 'o'){
$word = $word . 's';
array_push($out, $word);
continue;
}else if($l == 'a' || $l == 'i' || $l == 'y' || $l == 'u'){
$word = substr_replace($word ,"", -1);
$word = $word . 'os';
array_push($out, $word);
continue;
}
array_push($out, $word);
}
array_push($out, ", sak");
array_push($out, "povedz");
array_push($out, "ty");
array_push($out, "ne");
$outStr = implode(" ", $out);
echo $outStr;
}
?>