Last Updated: October 20, 2017
·
714
· pepsiphone

You think,know the answer,eh? in_array() v array_search() v foreach v array_flip+isset

Compare usual methods to search in arrays
https://github.com/hosseinmousavi/php-fastest-array-lookup
/////////////////////////
For Test I Create a Haystack Array with 100,000 Items and 200 Character Length Each and Choosing a Needle at the End of It. The Is the Result by Windows 10+4G Ram:

///////////////////////// found by inarray takes 0.0015938282012939 seconds
///////////////////////// found by array
search takes 0.001533031463623 seconds
///////////////////////// found by foreach+"==" operator takes 0.028446912765503 seconds
///////////////////////// found by array_flip+isset takes 0.10690093040466 seconds