|
Posted by Toby A Inkster on 04/12/07 11:15
Vince Morgan wrote:
> Toby A Inkster wrote:
>
>> 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"?
A pointer in the C sense of the word is (more or less) an exact memory
address for a piece of data.
The internal pointer in a PHP array has a far more ethereal nature.
Exactly how it works is an enigma wrapped in a riddle and shrouded by
mystery. We don't have direct access to the pointer, but can see its
ghostly effects in the list of functions I mentioned in my previous
post.
It's exact implementation in the PHP source code may well be as a C
pointer, but that doesn't (and shouldn't) matter to a person who's using
PHP arrays. The internal implementation as might well change for each new
version of PHP which is released -- as far as they're concerned, it
doesn't matter, as long as each(), next() and so on keep working as they
do.
> Something similar to an itterator in C++ ?
The array is, yes.
PHP 5 has iterators too.
--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux
* = I'm getting there!
[Back to original message]
|