DEV Community

Discussion on: How to Search in a PHP Associative Array – Fast tips

Collapse
 
ilvalerione profile image
Valerio Inspector.dev • Edited

The main point between foreach and array_map is that array_map involve a function call. That's why I chose to make a comparison on them. To understand if the function call has an impact.

Collapse
 
sirzarganwar profile image
Martin Jirasek • Edited

OK, but test something else than search functions is irrelevant because in_array, array_filter, ... are implemented different than array_map and results are not comparable.

For example array_column is faster than foreach implementation.