From: [EMAIL PROTECTED]
Operating system: Linux
PHP version: 5CVS-2003-10-24 (dev)
PHP Bug Type: Arrays related
Bug description: $array[] = $otherarray does not work as expected
Description:
------------
See expected and actual result to find out the difference. With CGI build
from same source both examples work as expected.
Reproduce code:
---------------
example 1:
<?php
$aTestInner = array();
$aTestInner['foo'] = 'content of $aTestInner[\'foo\']';
$aTestInner['bar'] = 'content of $aTestInner[\'bar\']';
$aTestOuter[] = $aTestInner;
$aTestOuter[] = $aTestInner;
$aTestOuter[] = $aTestInner;
echo '<pre>';
var_dump($aTestOuter);
echo '</pre>';
?>
------------------------------------------------------------
example 2:
<?php
for ($iLoop = 0; $iLoop < 3; $iLoop++) {
$aTestInner = array();
$aTestInner['foo'] = $iLoop . ': content of $aTestInner[\'foo\']';
$aTestInner['bar'] = $iLoop . ': content of $aTestInner[\'bar\']';
$aTestOuter[] = $aTestInner;
}
echo '<pre>';
var_dump($aTestOuter);
echo '</pre>';
?>
Expected result:
----------------
example 1:
array(3) {
[0]=>
array(2) {
["foo"]=>
string(29) "content of $aTestInner['foo']"
["bar"]=>
string(29) "content of $aTestInner['bar']"
}
[1]=>
array(2) {
["foo"]=>
string(29) "content of $aTestInner['foo']"
["bar"]=>
string(29) "content of $aTestInner['bar']"
}
[2]=>
array(2) {
["foo"]=>
string(29) "content of $aTestInner['foo']"
["bar"]=>
string(29) "content of $aTestInner['bar']"
}
}
------------------------------------------------------------
example 2:
array(3) {
[0]=>
array(2) {
["foo"]=>
string(32) "0: content of $aTestInner['foo']"
["bar"]=>
string(32) "0: content of $aTestInner['bar']"
}
[1]=>
array(2) {
["foo"]=>
string(32) "1: content of $aTestInner['foo']"
["bar"]=>
string(32) "1: content of $aTestInner['bar']"
}
[2]=>
array(2) {
["foo"]=>
string(32) "2: content of $aTestInner['foo']"
["bar"]=>
string(32) "2: content of $aTestInner['bar']"
}
}
Actual result:
--------------
example 1:
array(3) {
[0]=>
array(0) {
}
[1]=>
array(2) {
["foo"]=>
string(29) "content of $aTestInner['foo']"
["bar"]=>
string(29) "content of $aTestInner['bar']"
}
[2]=>
array(2) {
["foo"]=>
string(29) "content of $aTestInner['foo']"
["bar"]=>
string(29) "content of $aTestInner['bar']"
}
}
------------------------------------------------------------
example 2:
array(3) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
[2]=>
array(0) {
}
}
--
Edit bug report at http://bugs.php.net/?id=25976&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=25976&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=25976&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=25976&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=25976&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=25976&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=25976&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=25976&r=support
Expected behavior: http://bugs.php.net/fix.php?id=25976&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=25976&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=25976&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=25976&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=25976&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=25976&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=25976&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=25976&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=25976&r=float