note 65125 added to function.array-merge
| From: | magicianeer at yahoo dot com | Date: | Mon, 24 Apr 2006 20:00:53 +0000 |
| Subject: | note 65125 added to function.array-merge | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-109606@lists.php.net to get a copy of this message | ||
Re: Johannes
You cannot casually replace
<?php $this->content = array_merge($this->content,$new_content); ?>
with this
<?php
foreach ($new_content as $piece) {
$this->content[] = $piece;
}
?>
because the foreach loop does Append, not a true Merge (thats why its faster). If $new_content
contains some of the same data as $this->content, then you will get duplicates.
----
Server IP: 64.71.164.2
Probable Submitter: 65.202.100.45
----
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/function.array-merge.php
Edit -- http://master.php.net/note/edit/65125
Del: integrated -- http://master.php.net/note/delete/65125/integrated
Del: useless -- http://master.php.net/note/delete/65125/useless
Del: bad code -- http://master.php.net/note/delete/65125/bad+code
Del: spam -- http://master.php.net/note/delete/65125/spam
Del: non-english -- http://master.php.net/note/delete/65125/non-english
Del: in docs -- http://master.php.net/note/delete/65125/in+docs
Del: other reasons-- http://master.php.net/note/delete/65125
Reject -- http://master.php.net/note/reject/65125
Search -- http://master.php.net/manage/user-notes.php