php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #3445 Problem with copying arrays....
Submitted: 2000-02-10 05:10 UTC Modified: 2000-02-17 20:21 UTC
From: faisal at nasim dot org Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 4.0 Beta 3 OS: Windows/Linux RH6
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: faisal at nasim dot org
New email:
PHP Version: OS:

 

 [2000-02-10 05:10 UTC] faisal at nasim dot org
[Posted to PHP4BETA list too]

Example: (as I stated)

<?
  class myclass
  {
    var $MYARRAY;

    function myclass ()
    {
      $this->MYARRAY[] = "faisal";
      $this->MYARRAY[] = "nasim";
    }
    function test ()
    {
      $x = $this -> MYARRAY; # I want a copy!
      unset ( $x[0] );
    }
  }
  $test = new myclass;
  print count ( $test -> MYARRAY ) . "<BR>"; # 2
  $test -> test ();
  print count ( $test -> MYARRAY ) . "<BR>"; # 1 !!
?>

The second returns 1 which is incorrect, since I never referenced the array, i wanted the copy instead!


Here is a test case submitted by Mr. Zeev, in reply to the message:

:

$foo[] = 1;
$foo[] = 2;
$bar = $foo;
unset($foo[0]);
print count($foo)."\n";
print count($bar)."\n";


I thought it was a problem with arrays with classes, but it turned out to be a buggy bug in the array structure....

Hope you'll nab this one (and quick!) ;)

Thank you.

There is no field for name in your form, I wonder if you need it! If you do, its Faisal.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-02-17 20:21 UTC] andi at cvs dot php dot net
This has been fixed in the current CVS.
Thanks for the good bug report.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 03:01:32 2024 UTC