note 36173 deleted from function.array-merge by salathe

From: Date: Mon, 06 Sep 2021 22:46:13 +0000
Subject: note 36173 deleted from function.array-merge by salathe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-216903@lists.php.net to get a copy of this message
Note Submitter: loner at psknet dot !NOSPAM!com ---- 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.

« previous php.notes (#216903) next »