Bug #18543 Updated: Array returned from function with pointer at end
ID: 18543
Updated by: mikeboulet@newfangled.com
Reported By: mikeboulet@newfangled.com
Status: Bogus
Bug Type: Arrays related
Operating System: Win2K/Linux RH 7.1
PHP Version: 4.2.2
New Comment:
Just so you know, I did a lot of looking before I posted this bug. I
still cannot find where in the php reference that it describes this
behaviour. Do you know where this is documented?
This does work in PHP 4.0.6. I originally wrote the code under 4.0.6
and recently migrated the server to the 4.2.1/2 version.
Any ideas why the switch of behaviors? Was it a bug in php 4.0.6?
Thanks!
Previous Comments:
------------------------------------------------------------------------
[2002-07-24 13:50:27] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Use reset() or foreach()
------------------------------------------------------------------------
[2002-07-24 13:28:45] mikeboulet@newfangled.com
It is expected that the $msgs array passed back out of the test()
function call would have a pointer pointing to the first item. I
confirmed that this works correctly under PHP 4.0.6.
It doesn't work under 4.2.1 either.
Notice the output of the print_r()
// TEST SCRIPT
$newmsgs = test();
print_r( current( $newmsgs ));
function test()
{
$msgs[][a] = 10;
$msgs[][b] = 20;
$msgs[][c] = 30;
$msgs[][d] = 40;
$msgs[][e] = 50;
while( list( $idx, $msg ) = each( $msgs ) )
{
}
return $msgs;
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=18543&edit=1
Thread (3 messages)