Date: 11/02/00
- Next message: ronabop <email protected>: "[PHP-DEV] PHP 4.0 Bug #7601 Updated: Documentation Inconsistency"
- Previous message: Fred Hirsch: "[PHP-DEV] Re: PHP 4.0 Bug #6425 Updated: date() parsing functionality provides unexpected results."
- Next in thread: stas <email protected>: "[PHP-DEV] PHP 4.0 Bug #7578 Updated: next() and current() do not return referenceing arrays"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
ID: 7578
User Update by: mog <email protected>
Old-Status: Closed
Status: Open
Bug Type: Arrays related
Description: next() and current() do not return referenceing arrays
1. yes, i have read the manual on references explained.
2. ok, array(&$array2) might not work but i can't see why.
what if we make it like this? shouldn't this work
or it should work like this if current(), reset(), prev() and next() were modified to return references instead.
<?PHP
$array = array(array(0,1,2));
print current(current($array))."<br>"; // returns 0
print "<b>Try 1!</b><br>";
print next(current($array))."<br>"; // returns 1, correct but the internal pointer is only moved in the copy current() returned
print current(current($array))."<br>"; // returns 0, wrong, should be 1
print current($array[0])."<br>"; //returns 0, wrong, should be 1
print "<b>Try 2!</b><br>";
print next($array[0])."<br>";
print current(current($array))."<br>"; // returns 0, wrong, should be 1
print current($array[0])."<br>"; // returns 1, yes, correct! but the code above still didn't work!
?>
I really think that this behaviour should be changed, i need it for a project i'm working with.
Previous Comments:
---------------------------------------------------------------------------
[2000-11-01 19:43:52] waldschrott <email protected>
you simply can´t do it that way, please read the manual on foreach() etc. and that additional "&" in
> $array = array(&$array2);
has absolutely no effect here, at least not what you expect it to do (please also read "references explained")
> print next(current($array))."<br>"; // returns 1, correct > but the internal
> pointer is only moved in the copy current() returned
sure, current($array) returns a copy and thus all results you´ve mentioned are fine
---------------------------------------------------------------------------
[2000-11-01 19:29:27] mog <email protected>
i hope you can see what is wrong in the code below
<?PHP
$array2 = array(0,1,2);
$array = array(&$array2);
print current(current($array))."<br>"; // returns 0
print "<b>Try 1!</b><br>";
print next(current($array))."<br>"; // returns 1, correct but the internal pointer is only moved in the copy current() returned
print current(current($array))."<br>"; // returns 0, wrong, should be 1
print current($array2)."<br>"; //returns 0, wrong, should be 1
print "<b>Try 2!</b><br>";
print next($array[0])."<br>";
print current(current($array))."<br>"; // returns 0, wrong, should be 1
print current($array[0])."<br>"; // returns 1, yes, correct! but the code above still didn't work!
?>
---------------------------------------------------------------------------
Full Bug description available at: http://bugs.php.net/?id=7578
-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: ronabop <email protected>: "[PHP-DEV] PHP 4.0 Bug #7601 Updated: Documentation Inconsistency"
- Previous message: Fred Hirsch: "[PHP-DEV] Re: PHP 4.0 Bug #6425 Updated: date() parsing functionality provides unexpected results."
- Next in thread: stas <email protected>: "[PHP-DEV] PHP 4.0 Bug #7578 Updated: next() and current() do not return referenceing arrays"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

