for ($i = 0; $i < @array; $i++) { if (matches($array[$i])) { $found = $array[$i-1]; } }