Swapping foreach for array_map.