note 102859 deleted from function.array-replace-recursive by danbrown

From: Date: Thu, 10 Mar 2011 15:15:59 +0000
Subject: note 102859 deleted from function.array-replace-recursive by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-177742@lists.php.net to get a copy of this message
Note Submitter: marcovtwout at hotmail dot com ---- If you want to use array_replace_recursive() on just two arrays in PHP <5.3, you can use this simple function: <?php if (!function_exists('array_replace_recursive')) { function array_replace_recursive($a,$b) { foreach($b as $k=>$v) { if(is_array($v) && isset($a[$k]) && is_array($a[$k])) $a[$k]=array_replace_recursive($a[$k],$v); else $a[$k]=$v; } return $a; } } ?> Adapted from: http://www.yiiframework.com/doc/api/1.1/CMap/#mergeArray-detail

« previous php.notes (#177742) next »