note 40269 deleted from function.array-unshift by irchtml
| From: | irchtml@php.net | Date: | Fri, 27 Feb 2004 00:12:17 +0000 |
| Subject: | note 40269 deleted from function.array-unshift by irchtml | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-65856@lists.php.net to get a copy of this message | ||
Note Submitter: php@electricsurfer.com
----
unshifting of a reference !
<?php
/**
* @return int
* @param $array array
* @param $value mixed
* @desc Prepend a reference to an element to the beginning of an array. Renumbers numeric keys, so
$value is always inserted to $array[0]
*/
function array_unshift_ref(&$array, &$value)
{
$return = array_unshift($array,'');
reset($array);
$array[key($array)] =& $value;
return $return;
}
?>