php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25976 $array[] = $otherarray does not work as expected
Submitted: 2003-10-24 09:46 UTC Modified: 2004-02-29 06:41 UTC
Votes:3
Avg. Score:3.7 ± 1.9
Reproduced:1 of 2 (50.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: k.schroeder@php.net Assigned:
Status: Closed Package: Arrays related
PHP Version: 5CVS-2003-10-27 (dev) OS: Linux
Private report: No CVE-ID: None
 [2003-10-24 09:46 UTC] k.schroeder@php.net
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) {
  }
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-10-24 11:34 UTC] tony2001 at phpclub dot net
Try to update your PHP from CVS, to run ./cvsclean and to build it once more.
I can't reproduce this with latest CVS.
 [2003-10-24 14:55 UTC] k.schroeder@php.net
I've updated my PHP version from CVS and rebuild, but same problem. See http://kai.cowiki.org/tests/test.array.php and http://kai.cowiki.org/tests/test.array2.php.
 [2003-10-27 01:20 UTC] tony2001@php.net
Please, provide more info about your config and OS.
What version of apache do you use?
Have you try this examples with PHP-CLI ?
 [2003-10-27 06:00 UTC] k.schroeder@php.net
Hi Antony,

see http://kai.cowiki.org/_info.php for details.
 [2003-10-27 07:04 UTC] tony2001@php.net
Sorry, I get "Connection refused" by this URL all time.
 [2003-10-29 14:30 UTC] moriyoshi@php.net
I suspect this problem is caused by some funky accelerator / cacher. Please make sure that the problem is also reproducible without such things! (The same thing applies for your other reports related to coWiki, such as bug #25985).



 [2003-11-03 14:07 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.


 [2004-02-29 06:41 UTC] k.schroeder@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 04 11:01:32 2024 UTC