Why are these so brilliantly hidden when it comes to PHP"s
Why are these so brilliantly hidden when it comes to PHP"s
am 04.01.2008 14:26:00 von adam.timberlake
I was reading the following article yesterday:
http://www.talkphp.com/vbarticles.php?do=article&articleid=4 1&title=using-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.
My question is... what do you use internal pointers for, and why?
Re: Why are these so brilliantly hidden when it comes to PHP"s functions...?
am 04.01.2008 14:30:52 von Jerry Stuckle
adam.timberlake@gmail.com wrote:
> I was reading the following article yesterday:
> http://www.talkphp.com/vbarticles.php?do=article&articleid=4 1&title=using-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.
>
> My question is... what do you use internal pointers for, and why?
>
I use them a fair amount. Sometimes you need to run through an array,
and foreach() just doesn't do what you need (or makes the code more
complicated).
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Re: Why are these so brilliantly hidden when it comes to PHP"s functions...?
am 04.01.2008 18:54:02 von Steve
"Jerry Stuckle" wrote in message
news:6KmdnRk59_ChqOPanZ2dnUVZ_jydnZ2d@comcast.com...
> adam.timberlake@gmail.com wrote:
>> I was reading the following article yesterday:
>> http://www.talkphp.com/vbarticles.php?do=article&articleid=4 1&title=using-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.
>>
>> My question is... what do you use internal pointers for, and why?
>>
>
> I use them a fair amount. Sometimes you need to run through an array, and
> foreach() just doesn't do what you need (or makes the code more
> complicated).
lol. you get on to the op for multiposting and tell him you've answered his
question here. this is an answer?! your only good point was not
multiposting. however, i'm sure no one in alt.comp.lang.php will miss this
'answer'...as it does nothing for anyone.
why not tell the op *how* you use them and give an example of *how* your use
does something that foreach doesn't (or doesn't easily) do? hell, i'd be
very interested in THAT myself. i can't think of a situation that would
apply.
a better answer is that most languages have these constructs. typically in
more formal languages there is an iterator interface whereby you can can
impliment into a strongly typed collection object that will contain only
those types of items. your implimenting object/collection keeps track of the
'pointer' spoken about in the article and exposes those standard pointer
functions. implementing said interface allows the language to iterate, i.e.
foreach, the items even though you may have heavily customized your
collection. i would assume that having said little known pointer functions
would allow forward compatibility should php start to become more strongly
data typed in future versions.
AND, funny how the writer of the article uses the word internal 'pointer'.
count how many times. i couldn't be laughing harder.
Re: Why are these so brilliantly hidden when it comes to PHP"s functions...?
am 04.01.2008 20:54:32 von unknown
Post removed (X-No-Archive: yes)
Re: Why are these so brilliantly hidden when it comes to PHP"s functions...?
am 05.01.2008 03:27:30 von Jerry Stuckle
Tom wrote:
> On Fri, 04 Jan 2008 08:30:52 -0500, Jerry Stuckle wrote...
>> adam.timberlake@gmail.com wrote:
>>> I was reading the following article yesterday:
>>> http://www.talkphp.com/vbarticles.php?do=article&articleid=4 1&title=using-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.
>>>
>>> My question is... what do you use internal pointers for, and why?
>>>
>> I use them a fair amount. Sometimes you need to run through an array,
>> and foreach() just doesn't do what you need (or makes the code more
>> complicated).
>>
>
>
> I've gotten into the habit of using a for or foreach loop when I need to look at
> all the values. I haven't tried using these before, but definitely could come in
> handy down the road.
>
> Tom
Yep, they do - especially when you want extra tests to exit the loop.
It can make your code cleaner.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================