![]() |
Foreach
Just another method I guess :P
PHP Code:
This can be simplified but I was just having fun. :] |
|
Anyone care to benchmark? I'm almost sure the foreach is faster but it's nice to know none-the-less. (I'd do it but I'm shamlessly browsing whilst I'm supposed to be working)
|
Quote:
PHP Code:
|
It'll be the
$key => $value way by a long way, in terms of speed. We're just being silly :-) |
Quote:
PHP Code:
|
Actually, there is a faster way for doing a foreach with key and value:
PHP Code:
|
Quote:
|
Readability/Organisation > Speed.
|
What about array_walk()?
|
Not sure what are you doing here. Why don't you like foreach ?? :S
Well, if you want some weird stuff: PHP Code:
|
PHP Code:
Figure out what I changed xD |
Quote:
It would give the same result.... (++$num) Of course I forgot to put global $num, $ar.... |
Quote:
|
|
Damn, you guys got too much spare time.
:-) |
Quote:
|
| All times are GMT. The time now is 06:52 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0