forked from faisal2410/php_projects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring_tool.php
More file actions
122 lines (120 loc) · 2.78 KB
/
string_tool.php
File metadata and controls
122 lines (120 loc) · 2.78 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<!DOCTYPE html>
<html>
<head>
<title>String Manipulation Tool</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f2f2f2;
}
.container {
width: 80%;
margin: 0 auto;
padding: 20px;
background-color: #fff;
box-shadow: 0 0 10px rgba(0,0,0,0.2);
}
h1 {
margin-top: 0;
}
form {
display: flex;
flex-wrap: wrap;
margin-bottom: 20px;
}
label {
width: 100%;
margin-bottom: 5px;
}
input[type="text"], select {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
font-size: 16px;
margin-bottom: 10px;
box-sizing: border-box;
}
input[type="submit"] {
background-color: #4CAF50;
color: white;
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
}
input[type="submit"]:hover {
background-color: #3e8e41;
}
p {
font-size: 18px;
margin: 0;
padding: 10px;
background-color: #e6e6e6;
border: 1px solid #ccc;
border-radius: 5px;
}
</style>
</head>
<body>
<div class="container">
<h1>String Manipulation Tool</h1>
<form action="string_tool.php" method="post">
<label for="input_string">Enter a string:</label>
<input type="text" id="input_string" name="input_string">
<label for="string_function">Select a function:</label>
<select id="string_function" name="string_function">
<option value="strlen">strlen</option>
<option value="strrev">strrev</option>
<option value="strtoupper">strtoupper</option>
<option value="strtolower">strtolower</option>
<option value="ucfirst">ucfirst</option>
<option value="ucwords">ucwords</option>
<option value="trim">trim</option>
<option value="str_repeat">Repeat 3 times</option>
</select>
<input type="submit" value="Manipulate String">
</form>
<?php
if (isset($_POST['input_string']) && isset($_POST['string_function'])) {
$input_string = $_POST['input_string'];
$string_function = $_POST['string_function'];
switch ($string_function) {
case 'strlen':
$result = strlen($input_string);
break;
case 'strrev':
$result = strrev($input_string);
break;
case 'strtoupper':
$result = strtoupper($input_string);
break;
case 'strtolower':
$result = strtolower($input_string);
break;
case 'ucfirst':
$result = ucfirst($input_string);
break;
case 'ucwords':
$result = ucwords($input_string);
break;
case 'trim':
$result = trim($input_string);
break;
case 'str_repeat':
$result = str_repeat($input_string,3);
break;
default:
$result = 'Invalid';
}
?>
<h2><?php echo "The result of " . $string_function . " Input: " . $input_string . " Output: " . $result;?></h2>
<?php
}
?>
</div>
</body>
</html>