#22104 [Opn->Fbk]: problem with adding value to multiplie dimensional arrays

From: Date: Sat, 08 Feb 2003 05:09:08 +0000
Subject: #22104 [Opn->Fbk]: problem with adding value to multiplie dimensional arrays
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-32442@lists.php.net to get a copy of this message
 ID:               22104
 Updated by:       sniper@php.net
 Reported By:      canholms@hotmail.com
-Status:           Open
+Status:           Feedback
 Bug Type:         Arrays related
 Operating System: Windows
 PHP Version:      4.3.0
 New Comment:

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.



Previous Comments:
------------------------------------------------------------------------

[2003-02-07 11:20:19] canholms@hotmail.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 07:16:53] 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 01:04:09] canholms@hotmail.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...

------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=22104&edit=1



Thread (5 messages)

« previous php.bugs (#32442) next »