IndexOf An Array Element
Join the DZone community and get the full member experience.Join For Free
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.
Data structure Element
Opinions expressed by DZone contributors are their own.