New in PHP 8.6: Narrowing the array_map vs foreach performance gap
With PHP 8.6, array_map gets about 10% faster in a synthetic benchmark — with zero changes to your code. My colleague Tim contributed the engine-level optimization that makes this possible. With PHP 8.6, the engine will automatically improve the following code: To turn array_map into a foreach loop as an engine optimization, PHP sees and executes this code as if it was written like this: This improves performance in a synthetic benchmark by about 10%.