I wrote a function to search in an array using a * as wildcard and optional returning the matched value or even the next using an offset

Have fun...
GeSHi (php):
function in_Arrayw($haystack, $needle, $offset=0) {
$i = 0;
foreach ($haystack as $value){
if (eregi($needle,
$value)!=
false){ $value = ($offset==0) ? $value : $haystack[$i+$offset];
return $value;
}
$i++;
}
return false;
}
Created by GeSHI 1.0.7.20
Usage :
GeSHi (php):
$arr =
array('marook',
'online',
'website');
echo in_arrayw
($arr,
'mar*'); returns marook
echo in_arrayw
($arr,
'mar*',
1); returns online
echo in_arrayw
($arr,
'w*'); returns website
echo in_arrayw
($arr,
'*e'); returns online
echo in_arrayw
($arr,
'test*'); returns
false
Created by GeSHI 1.0.7.20