|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #18543 Array returned from function with pointer at end
Submitted: 2002-07-24 13:28 UTC Modified: 2002-07-24 14:04 UTC
From: mikeboulet at newfangled dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 4.2.2 OS: Win2K/Linux RH 7.1
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: mikeboulet at newfangled dot com
New email:
PHP Version: OS:


 [2002-07-24 13:28 UTC] mikeboulet at newfangled dot 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()


$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;


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-07-24 13:50 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

Use reset() or foreach()
 [2002-07-24 14:04 UTC] mikeboulet at newfangled dot com
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?

PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sat Dec 03 19:05:55 2022 UTC