I have an array with many elements. What would be the most efficient way to check to see if a string is contained somewhere in that array, line by line? I suppose a foreach loop?
you will have to check line by line, or element by element of the array. It might be faster to use a loop and the "last" flow control operator if these are big arrays and you only need to know if the variable is in the array and not how many times it's in the array. grep is fast though and you would have to run checks with your actual data to see which method is better for our situation.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.