note 36173 added to function.array-merge
| From: | loner at psknet dot !NOSPAM!com | Date: | Mon, 29 Sep 2003 19:00:35 +0000 |
| Subject: | note 36173 added to function.array-merge | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-57283@lists.php.net to get a copy of this message | ||
I got tripped up for a few days when I tried to merge a (previously serialized) array into a object.
If it doesn't make sense, think about it... To someone fairly new, it could... Anyway, here is
what I did:
(It's obviously not recursive, but easy to make that way)
<?php
function array_object_merge(&$object, $array) {
foreach ($array as $key => $value)
$object->{$key} = $value;
}
?>
Simple problem, but concevibly easy to get stuck on.
----
Manual Page -- http://www.php.net/manual/en/function.array-merge.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+36173
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+36173&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+36173&report=yes