php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22104 problem with adding value to multiplie dimensional arrays
Submitted: 2003-02-07 01:04 UTC Modified: 2003-02-20 08:09 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: canholms at hotmail dot com Assigned:
Status: No Feedback Package: Arrays related
PHP Version: 4.3.0 OS: Windows
Private report: No CVE-ID: None
 [2003-02-07 01:04 UTC] canholms at hotmail dot com
foreach($array[0] as $key => $value)
{
    $array[1]=1;
}

This will change the value on $array[0] too, i can't explain it more. I tested with serialize and the value on the variable gets very strange...

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-02-07 07:16 UTC] andrey@php.net
 I cannot simulate what you say. Here is script that I wrote to test. Test with it. Please provide good feedback as well as an example code (as small as possible please).

<pre>
<?php
$array = array("0" => array(1=>"one",2=>"two", 3=>"three"),
"1" => array(1=>"One",2=>"Two", 3=>"Three"),
	);
var_dump($array);
foreach($array[0] as $key => $value)
{
    $array[1]=1;
}

var_dump($array);
?>
 [2003-02-07 11:20 UTC] canholms at hotmail dot com
you will see what i mean if you do following:


<pre>
<?php
$array = array("0" => array(1=>"one",2=>"two", 3=>"three"),
"1" => array(1=>"One",2=>"Two", 3=>"Three"),
	);
var_dump($array);
foreach($array[0] as $key => $value)
{
    $array[1][]=1;
}

var_dump($array);
?>
 [2003-02-07 23:09 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-STABLE-latest.zip

I can not reproduce this with latest stable CVS snapshot.

 [2003-02-20 08:09 UTC] sniper@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 06:01:30 2024 UTC