Arrays inside classes

From: Date: Wed, 09 Feb 2000 08:24:39 +0000
Subject: Arrays inside classes
Groups: php.version4 
Request: Send a blank email to php-version4+get-9972@lists.php.net to get a copy of this message
Hi, Can anybody tell me how to make the copy of array when accessing through classes' functions? TEST CASE: <? 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 !! ?> I would like to make a copy of $MYARRAY in test().... I am not using & to point to the same address, so by default it should create a copy and not a reference! Any thoughts? Thank you. Faisal Nasim faisal@nasim.org

« previous php.version4 (#9972) next »