Finds the first instance of an element ($needle) in an array ($haystack). It works in ascending order (from element 0 to the array's length), can be easily modified to work in reverse if required. Will return either the index of the first occurance of false if hasn't been found.
function indexOf($needle, $haystack) { // conversion of JavaScripts most awesome
for ($i=0;$i<count($haystack);$i++) { // indexOf function. Searches an array for
if ($haystack[$i] == $needle) { // a value and returns the index of the *first*
return $i; // occurance
}
}
return false;
}