|
Posted by Jerry Stuckle on 04/12/07 22:08
Vince Morgan wrote:
> "Vince Morgan" <vinhar@REMOVEoptusnet.com.au> wrote in message
> news:461e08a4$0$9771$afc38c87@news.optusnet.com.au...
>> "Toby A Inkster" <usenet200703@tobyinkster.co.uk> wrote in message
>> news:gr81f4-4kp.ln1@ophelia.g5n.co.uk...
>>> Tamagafk wrote:
>>>
>>>> Hi! Looks like there is a bug in php. If I have function which uses
>>>> foreach to run trough array recursively, the lop-level foreach
>>>> interupted by lover-level foreach'es. If I use simply 'for' everything
>>>> is ok.
>>> It's not a bug -- it's a "feature". Internally, arrays in PHP have a
>>> "pointer" (not in the C sense of the word) which points at the "current"
>> Why not in the "C sense"?
>> Something similar to an itterator in C++ ?
>>
>> TIA
>> Vince
>>
>
> I guess I didn't ask that q very well at all.
> I'm familiar with pointers in C/C++, and iterators in C++, they are
> languages I have most experience with.
> However, I was thinking that they may be in some ways similar to say, a
> vector iterator, without regard for methods etc.
> I meant in a very general way, but I think it was probably a silly question
> realy.
> Trying to cheat my way into a greater understanding of the unerlying
> implementation without doing the reading I guess ;)
> Thank you for the reply though,
> Regards,
> Vince
>
>
Vince,
But the whole point of an iterator is that it has methods you can use to
manipulate it. The PHP internal pointer does not - you can only
manipulate the pointer through the array itself.
Additionally, you can define multiple (or no) iterators for the same
list/array/whatever because it is a separate object. But in PHP you
have exactly one pointer which is tied to the array.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|