-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoperation.php
95 lines (75 loc) · 2.23 KB
/
operation.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<?php
if (isset($_POST['word_list']) > 0 && isset($_POST['choice']) && isset($_POST['separator'])){
$words = $_POST['word_list'];
//Word Choice Operation
switch ($_POST['choice']){
case 'small_word':
$words = strtolower($words);
break;
case 'big_word':
$words = strtoupper($words);
break;
case 'capital_letter_word':
$words = mb_convert_case($words, MB_CASE_TITLE, "UTF-8");
break;
case 'just_separate':
echo "Your Choice \"Just Separate\""."<hr>";
break;
default:
echo "NOT FOUND";
break;
}
//Seperator Operation
if ($_POST['separator'] == "myself" && strlen($_POST['another_separator']) == 0){
die("Missing Separator");
}
else if ($_POST['separator'] != "myself" && strlen($_POST['another_separator']) > 0){
die("Do not select more than one separator");
}
else if ($_POST['separator'] == "myself" && strlen($_POST['another_separator']) > 0){
$separator = $_POST['another_separator'];
$words = explode($separator, $words);
}
else{
$separator = $_POST['separator'];
switch ($separator){
case 'space':
$words = explode(" ", $words);
break;
case 'vertical_line':
$words = explode("|", $words);
break;
case 'and':
$words = explode("&", $words);
break;
case 'line_break':
$words = explode("\n", $words);
break;
}
}
if (isset($_POST['download_json'])){
$words = json_encode($words);
header('Content-Type: application/json');
header('Content-Disposition: attachment; filename=data.json');
file_put_contents('php://output', $words);
}
else if (isset($_POST['print_data'])){
print_r($words);
}
else if (isset($_POST['print_with_pre'])){
echo "<pre>";
print_r($words);
echo "</pre>";
}
}
else{
echo "Missing Information";
}
?>
</body>
</html>