Comparison of processing efficiency of php Array functions

when traversing an array to find a specific value, we often have many different methods, so we also hope that netizens who have done relevant tests or know the answer can help answer this question.
1, foreach traversal array to find a specific value
2, array_map traversal array to find a specific value
3, array_search traversal array to find a specific value
what are the performance differences among them? What order of magnitude of data will be the critical point for the significant differences in the efficiency of the three methods?


although it has not been actually tested, both foreach and arrapy_map are executed while interpreting, and only array_search is executed entirely in compiled code, so array_search should be the fastest.


use arrays of thousands, tens of thousands and millions to test respectively

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3224e-2bde5.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3224e-2bde5.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?