-
Notifications
You must be signed in to change notification settings - Fork 0
/
que7.php
37 lines (30 loc) · 887 Bytes
/
que7.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
<!--Write a PHP script to perform searching functionality from multi-dimensional array based on-->
<!--user inputted value.-->
<!--[Note: Multi-dimensional array has at least 3 x 3 and array value initialize array randomly]-->
<?php
$array = array(
array("Fenil", "Dhara", "Sahil"),
array("Rohan", "VishvasLathiya", "Om"),
array("Sunil", "Kevin", "Jay")
);
$flag = 0;
if (isset($_POST['submit'])) {
$search = $_POST['search'];
foreach ($array as $value) {
foreach ($value as $value1) {
if ($value1 == $search) {
echo "Found";
$flag = 1;
break;
}
}
}
if ($flag == 0) {
echo "Not Found";
}
}
?>
<form method="post">
<input type="text" name="search">
<input type="submit" name="submit" value="Search">
</form>