forked from georgioupanayiotis/PHP-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
small-capital-letter-count.php
46 lines (36 loc) · 1.13 KB
/
small-capital-letter-count.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
<div style="width:50%;">
<form method="post">
<div>
<label>Give Capital and Small Letters to Count</label>
<input type="text" name="string_word" placeholder="Give Capital and Small Letters to Count . . . . ." autofocus="autofocus" />
</div>
<button type="submit" name="count_letter">Count . . . . .</button>
</form>
<?php
function count_Capital_Letter($string_letter)
{
return strlen(preg_replace('/[^A-Z]+/', '', $string_letter));
}
function count_Small_Letter($string_letter)
{
return strlen(preg_replace('/[^a-z]+/', '', $string_letter));
}
if (isset($_POST['count_letter']))
{
$string_word = $_POST['string_word'];
$result1 = count_Capital_Letter($string_word);
$result2 = count_Small_Letter($string_word);
?>
<br />
<div>
<button type="button"><span>×</span></button>
The word given by the user is <strong style="font-size:20px;"><?php
echo $string_word; ?></strong>
</div>
<div>Count of Capital Letters is <strong style="font-size:20px;"><?php
echo $result1; ?></strong></div>
<div>Count of Small Letters is <strong style="font-size:20px;"><?php
echo $result2; ?></strong></div>
<?php
} ?>
</div>