note 63159 added to language.types.array
| From: | HenryCesbronLavau at osu1 dot php dot net | Date: | Tue, 14 Mar 2006 22:07:00 +0000 |
| Subject: | note 63159 added to language.types.array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-105817@lists.php.net to get a copy of this message | ||
To copy values from an array which contains arrays
db 05-Jan-2005 04:06 said : If you copy (=) an array which contains arrays it will be REFERENCED not
COPIED.
Well, this is only true since PHP 5.
Under PHP4, it is COPIED.
So be aware of this when porting code from PHP 4 to PHP 5 !
Now, if you want to copy the values (and not the references),
(instead of using array_diff as stated below, which won't work either under PHP 5)
just use :
$a2 = array_combine($a1, $a1);
----
Server IP: 147.32.160.17
Probable Submitter: 82.123.17.126
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/language.types.array.php
Edit -- http://master.php.net/note/edit/63159
Del: integrated -- http://master.php.net/note/delete/63159/integrated
Del: useless -- http://master.php.net/note/delete/63159/useless
Del: bad code -- http://master.php.net/note/delete/63159/bad+code
Del: spam -- http://master.php.net/note/delete/63159/spam
Del: non-english -- http://master.php.net/note/delete/63159/non-english
Del: in docs -- http://master.php.net/note/delete/63159/in+docs
Del: other reasons-- http://master.php.net/note/delete/63159
Reject -- http://master.php.net/note/reject/63159
Search -- http://master.php.net/manage/user-notes.php