-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1703.php
More file actions
40 lines (33 loc) · 760 Bytes
/
1703.php
File metadata and controls
40 lines (33 loc) · 760 Bytes
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
<?php
echo 'Hello world....';
function getChar(int $n): string
{
return chr($n);
}
echo getChar(65);
echo '<br>';
function strtoUp(string $str): string
{
return strtoupper($str);
}
echo strtoUp('dilip parmar');
echo '<br>';
function posAlpha(string $str): string
{
$str = strtolower($str);
$collect = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
$value = array_search($str, $collect);
$value += 1;
return "Position of alphabet:$value";
}
echo posAlpha('A');
echo "<br>";
function countSheeps(int $n)
{
$value = '';
for ($i = 1; $i <= $n; $i++) {
$value .= "$i sheep...";
}
return $value;
}
echo countSheeps(2);