note 108275 deleted from function.array-unshift by danbrown

From: Date: Fri, 13 Apr 2012 20:33:17 +0000
Subject: note 108275 deleted from function.array-unshift by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-187116@lists.php.net to get a copy of this message
Note Submitter: nachitox2000 [at] hotmail [dot]com ---- About the Anonymous @ 09-Feb-2012 09:13, Why would you return $arr if the parameter is a reference to the array ? I wouldn't return anything. Not tested, but I thing that this would work just fine: <?php function array_unshift_assoc(&$arr, $key, $val) { $arr = array_reverse($arr, true); $arr[$key] = $val; $arr = array_reverse($arr, true); } ?>

« previous php.notes (#187116) next »