Linear Search
Linear search, also known as sequential search is an algorithm for finding a target value within a list. It sequentially checks each element of the list for the target value until a match is found or until all the elements have been searched.
function Search($list, $data) {
$count = count($list);
for ($i = 0; $i < $count; $i++) {
if ($data == $list[$i]) return $i;
}
return -1;
}
Example
$list = array(153, 26, 364, 72, 321);
$index = Search($list, 364);
Output
index: 2