foreach() using current() strange beahvior

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

 



Please consider this code :

<?php
$a = array("One","Two","Three");

foreach ($a AS $k=>$v) {
}

var_dump(current($a));
// outputs boll(false);

that's expected as foreach moves the internal array pointer, it's
documented.

now consider this :

<?php
$a = array("One","Two","Three");

foreach ($a AS $k=>$v) {
current($a);
}

var_dump(current($a));
// outputs string("One");

When using the internal pointer just by calling current() (so not moving
it), the output of the foreach loop has changed ...
Can someone explain that ?

regards.

[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