-
Notifications
You must be signed in to change notification settings - Fork 0
/
24.php
50 lines (43 loc) · 1005 Bytes
/
24.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
47
48
49
50
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>24</title>
</head>
<body>
<form action="" method="post">
<input type="text" name="figures">
<select name="choose_figure">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
</select>
<input type="submit" name="sub" value="Посчитать">
</form>
</body>
</html>
<?php
if (isset($_POST['sub'])) {
if (is_numeric($_POST['figures'])) {
$figures = $_POST['figures'];
}
$choose_figure = $_POST['choose_figure'];
$count = how_many($figures, $choose_figure);
echo $count;
}
function how_many($a, $b) {
$count = 0;
for($i = 0; $i < strlen($a); $i++) {
if($a[$i] == $b) {
$count++;
}
}
return $count;
}
?>