4 ms·
this is interesting, I'd like to see a comparison with foreach vs. for too - just out of curiousity :) Also the $var == "" kind of suprised me, didn't know it w
by jfaucett 14y ago
this is interesting, I'd like to see a comparison with foreach vs. for too - just out of curiousity :) Also the $var == "" kind of suprised me, didn't know it was that bad, although I guess this does rarely happen since most probably use empty anyway.
- ihsw 14y agoThe $var == "" issue is more understandable when you realize that PHP attempts to do type coercion to test comparison for all data types, while the equality operator (triple equals, ===) does not attempt to do type coercion. Also, foreach(range(1, 1000 * 1000) as $i) will execute at roughly the same speed as for($i = 0, $count = 1000 * 1000; $i < $count; $i++), so the difference is negligible.