Thread: array_map speed
View Single Post
Old 01-10-2008, 01:50 AM   #3 (permalink)
Salathe
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

Hmm interesting. I tried three different approaches (array_map, for, foreach) with the following results.

Code:
Test took 7.684968 seconds to complete
Test array has 100 items
Average of 10,000 iterations, times in 1000ths of a second

array_map => 0.107439
foreach => 0.327824
for => 0.322589
Given those results, which contradict your own, it would appear that array_map is around 3 times faster than for/foreach -- for me at least.
Salathe is offline  
Reply With Quote