note 108275 added to function.array-unshift
| From: | nachitox2000 | Date: | Fri, 13 Apr 2012 12:22:12 +0000 |
| Subject: | note 108275 added to function.array-unshift | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-187104@lists.php.net to get a copy of this message | ||
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);
}
?>
----
Server IP: 190.2.55.64
Probable Submitter: 201.231.92.182
----
Manual Page -- http://www.php.net/manual/en/function.array-unshift.php
Edit -- https://master.php.net/note/edit/108275
Del: integrated -- https://master.php.net/note/delete/108275/integrated
Del: useless -- https://master.php.net/note/delete/108275/useless
Del: bad code -- https://master.php.net/note/delete/108275/bad+code
Del: spam -- https://master.php.net/note/delete/108275/spam
Del: non-english -- https://master.php.net/note/delete/108275/non-english
Del: in docs -- https://master.php.net/note/delete/108275/in+docs
Del: other reasons-- https://master.php.net/note/delete/108275
Reject -- https://master.php.net/note/reject/108275
Search -- https://master.php.net/manage/user-notes.php