|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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...
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 21:00:02 2025 UTC |
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); ?>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); ?>