-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirsttask.php
More file actions
38 lines (38 loc) · 1.02 KB
/
Copy pathfirsttask.php
File metadata and controls
38 lines (38 loc) · 1.02 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
<?php
function set()
{
if (isset($_GET['text'])) {
$name = $_GET['text'];
} else {
$name = NULL;
}
return $name;
}
$str = set();
function getlength($str)
{
$str_length = strlen($str);
return $str_length;
}
function showString($str)
{
echo "Final Converted String is :-".$str;
}
$length = getlength($str);
function changeCase(int $length, string $str)
{
if ($length<2) {
$cnvtstring = strtoupper($str);
showString($cnvtstring);
} elseif ($length>2 && strpos(trim($str),' ')==false) {
$cnvtstring = strtolower($str);
showString($cnvtstring);
} elseif ($length>2 && strpos(trim($str),' ')==true) {
$cnvtstring = ucfirst(strtolower($str));
showString($cnvtstring); } else {
$cnvtstring = "String is not understandable";
showString($cnvtstring);
}
}
changeCase($length, $str);
?>