|
Posted by Rik Wasmus on 01/04/08 13:41
On Fri, 04 Jan 2008 14:25:28 +0100, <adam.timberlake@gmail.com> wrote:
> I was reading the following article yesterday:
> http://www.talkphp.com/vbarticles.php?do=3Darticle&articleid=3D41&titl=
e=3Dusing-the-internal-array-pointers-to-access-elements-in-arrays
>
> What struck me while reading it was how very little we hear about the
> array internal pointers !! I've been in PHP now for a good 2 years,
> and I've never heard these little guys mentioned before.
It's because most of array actions can be done much more effectively & =
transparant with foreach() loops.
Before that, we had to do something like this:
$array =3D array(1,2,3,4,5,6);
//some code
reset($array);
while($item =3D each($array)){
echo "Key =3D ".$item['key'];
echo "Value =3D ".$item['value'];
}
> My question is... what do you use internal pointers for, and why?
Normally, I don't use an arrays pointer in PHP. Foreach is quite enough =
=
usually (possibly with an continue statement), and I use references to =
array items if not.
-- =
Rik Wasmus
Navigation:
[Reply to this message]
|