indexof function

Find index of needle in haystack