note 112282 added to function.array-replace

From: Date: Mon, 27 May 2013 13:43:31 +0000
Subject: note 112282 added to function.array-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-194966@lists.php.net to get a copy of this message
A little enhancement to w_barath at hotmail dot com function below that preserve keys order: <?php if (function_exists('array_replace') == false) { /** * Replace array_replace for PHP < 5.3 * * @return array */ function array_replace() { $array = array(); $n = func_num_args(); $keys = array_keys(func_get_arg(0)); while ($n-- >0) { $array += func_get_arg($n); } $rval = array(); foreach ($keys as $key) { $rval[$key] = $array[$key]; } return $rval; } } ?> ---- Server IP: 69.147.83.199 Probable Submitter: 193.127.190.21 ---- Manual Page -- http://php.net/manual/en/function.array-replace.php Edit -- https://master.php.net/note/edit/112282 Del: integrated -- https://master.php.net/note/delete/112282/integrated Del: useless -- https://master.php.net/note/delete/112282/useless Del: bad code -- https://master.php.net/note/delete/112282/bad+code Del: spam -- https://master.php.net/note/delete/112282/spam Del: non-english -- https://master.php.net/note/delete/112282/non-english Del: in docs -- https://master.php.net/note/delete/112282/in+docs Del: other reasons-- https://master.php.net/note/delete/112282 Reject -- https://master.php.net/note/reject/112282 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#194966) next »