Re: array_walk?
From: Kelvin Mackay (kelvin_at_nospam.sands-design.net)
Date: 02/20/05
- Next message: Ted G: "Validating directory and file path"
- Previous message: windandwaves: "speed"
- In reply to: comp.lang.php: "Re: array_walk?"
- Next in thread: Chung Leong: "Re: array_walk?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 20 Feb 2005 12:05:39 -0000
On 18 Feb 2005 11:30:30 -0800, comp.lang.php <phillip.s.powell@gmail.com>
wrote:
> I'm beginning to wonder myself since array_walk() has more limitations
> than us the foreach loop construct inasmuch as direct array
> manipulation is concerned.
>
> You don't have to reset the pointer before array_walk() whereas in
> foreach you would have to before using it to ensure the looping entails
> the entire array; that's the only advantage I can think off offhand.
Nope - www.php.net/foreach
"Note: When foreach first starts executing, the internal array pointer is
automatically reset to the first element of the array. This means that you
do not need to call reset() before a foreach loop."
>
> Phil
>
Presumeably the merit of array_walk is in avoiding code duplication where
you might otherwise have to use several identical foreach blocks
-- Kelvin
- Next message: Ted G: "Validating directory and file path"
- Previous message: windandwaves: "speed"
- In reply to: comp.lang.php: "Re: array_walk?"
- Next in thread: Chung Leong: "Re: array_walk?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|