Re: [PHP] PHP: inexplicable behaviour of pre- and post-increment operators

[email protected] (haliphax)
Newsgroups php.general
Message-ID <[email protected]>
> On Fri, Feb 26, 2010 at 11:01 PM, <[email protected]> wrote:
> > while ($i < $j) { $b[$i] = $a[$i++]; }          B.
> >
> > You get $b[0] = $a[1], and so on (as you would expect).
>

Wouldn't that be $b[0] = $a[0], with the value of $i being 1 *after* the
statement was finished executing? You used a post-decrement operator on $i
at the end of your statement, so I don't think that $i would be increased
before being used to index into the $a array.


// Todd
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.