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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 3 Mar 2010 08:21:06 -0600, haliphax@xxxxxxxxx (haliphax) wrote:

>> On Fri, Feb 26, 2010 at 11:01 PM, <clancy_1@xxxxxxxxxxxx> 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.

Try it!

Clancy

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux