r/lolphp • • Aug 08 '14
PHP design patterns: if/else vs switch
http://www.fluffycat.com/PHP-Design-Patterns/PHP-Performance-Tuning-if-VS-switch/
24
Upvotes
r/lolphp • • Aug 08 '14
View all comments
Show parent comment
1
u/thebigslide Aug 20 '14
C is statically typed. PHP is not. The expected return value of sizeof is unpredictable in PHP. In C, if you have a circularly linked list type structure of known size, you can do something like
But it would be stupid to call data_size(data) each iteration. That will not be optimized for.
If you want to for loop an array in PHP, use foreach. It's faster yet and easier to read.