The Zend Engine is programmed in C, if I remember correctly.  Strings in C
are really just pointers to character arrays, which is what you see here.
Because PHP is a wrapper of sorts, it is basically covering up the fact that
strings are character arrays.  The good programmers were nice enough to make
this an afterthought for all of us, but it looks like they still left C's
functionality intact.

Mike Frazer


"Martin Towell" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> it's treating a string as a character array - it's documented somewhere in
> the manual, can't remember where though :(   - not long ago someone was
> saying that the new way it to use curly-brackets, but square brackets
still
> work for backwark compatibility.
>
> -----Original Message-----
> From: v0idnull [mailto:[EMAIL PROTECTED]]
> Sent: Friday, January 25, 2002 8:57 AM
> To: PHP List
> Subject: [PHP] Arrays as pointers?
>
>
> A friend of mine showed me this code recently.
>
> function firstLogin_string() {
> mt_srand(make_seed());
> $pool = "AaBbCcDdEeFfGgHhIiJjKkLlM";
> $length = 26;
>   for($i=0; $i < $length; $i++) {
> $key .= $pool[mt_rand(0,strlen($pool)-1)];
>   }
> return $key;
> }
>
> look at the for loop. $pool is not an array but is being treated as such
and
> the key happens to be the position in $pool and it'll take that letter and
> save it to $key. I've never seen this done before. What is this method
> called and what other neat tricks can you do in respect to this?
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to