Search forwards and backwards in an array of strings