-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0104.php
More file actions
56 lines (53 loc) · 1.28 KB
/
0104.php
File metadata and controls
56 lines (53 loc) · 1.28 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
<?php
echo 'Hello world';
echo '<br>';
function reverseStr(string $str): string
{
// return strrev($str);
$val = explode(' ', $str);
// print_r($val);
$output = [];
foreach ($val as $key => $value) {
// echo strrev($value);
array_push($output, strrev($value));
}
// print_r($output);
return implode(' ', $output);
// return 'Hi';
}
echo reverseStr('My Name this Khan');
echo '<br>';
function reverseStr2(string $str): string
{
return (implode(' ', array_map('strrev', explode(' ', $str))));
}
echo reverseStr2('Jay mataji');
function reverseAry(array $ary): array
{
print_r($ary);
return array_reverse($ary);
return $ary;
}
print_r(reverseAry([1, 2, 3, 4]));
echo '<br>';
function printerError(string $str): string
{
// echo "myname \" khan \"";
// echo ord('a');
// echo ord('m');
$Ary = str_split($str);
$errorVal = 0;
foreach ($Ary as $key => $value) {
# code...
$num = ord($value);
if ($num >= 97 && $num <= 109) {
} else {
$errorVal++;
}
}
// echo $errorVal;
// echo strlen($str);
// return "printer_error(s) => \"" . $errorVal . '/' . strlen($str) . "\"";
return $errorVal . '/' . strlen($str);
}
echo printerError('aaabbbbhaijjjm');