Skip to content

Commit b1b4090

Browse files
committed
Trying to figure out this exercise. Wanting to create a function to
search through arrays.
1 parent 21c0db0 commit b1b4090

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

PHP/search_arrays.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
// first names
4+
$names = ['Tina', 'Dana', 'Mike', "Amy", 'Adam'];
5+
6+
$compare = ['Tina', 'Dean', 'Mel', 'Amy', 'Michael']
7+
8+
// array_search(needle, haystack)
9+
10+
function check_array($array, $element) {
11+
$query = array_search($array, $element);
12+
if ($query !== FALSE) {
13+
return TRUE;
14+
} else {
15+
return FALSE;
16+
}
17+
}
18+
19+
20+
?>

0 commit comments

Comments
 (0)