php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41434 foreach ($users as $key=>&$user) //error
Submitted: 2007-05-18 14:46 UTC Modified: 2007-05-18 14:50 UTC
From: leadaxe at yandex dot ru Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.2.2 OS: win
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: leadaxe at yandex dot ru
New email:
PHP Version: OS:

 

 [2007-05-18 14:46 UTC] leadaxe at yandex dot ru
Description:
------------
I think your mast look code/ Sorry but my english is not good



Reproduce code:
---------------
<?
	$users=explode('.',".1.2.3.4.");
	foreach ($users as $key=>&$user){
		if (empty($user))
			unset($users[$key]); //it bag?
		$user=1; //not work
	}
	var_dump($users); //see result

?>

Expected result:
----------------
array(6) {
  [1]=>
  &int(1)
  [2]=>
  &int(1)
  [3]=>
  &int(1)
  [4]=>
  &int(1)
}

Actual result:
--------------
array(4) {
  [1]=>
  string(1) "1"
  [2]=>
  string(1) "2"
  [3]=>
  string(1) "3"
  [4]=>
  string(1) "4"
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-05-18 14:50 UTC] tony2001@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Dec 02 18:00:01 2025 UTC