note 37278 deleted from function.array-unshift by cece
| From: | cece@php.net | Date: | Mon, 29 Nov 2004 13:25:31 +0000 |
| Subject: | note 37278 deleted from function.array-unshift by cece | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-81149@lists.php.net to get a copy of this message | ||
Note Submitter: lagroue
----
Since deprecation of call-time pass-by-reference, you can not unshift with a reference :
<?php
array_unshift ($a, &$v);
?>
If you'd like to unshift only one reference, here is a replacement function :
<?php
function array_unshift1 (& $iArray, $iValueWrappedInAnArray) {
$lNewArray = false;
foreach (array_keys ($iArray) as $lKey)
$lNewArray[$lKey+1] = $iArray[$lKey];
$iArray = array (& $iValueWrappedInAnArray[0]);
foreach ($lNewArray as $lValue)
$iArray[] = $lValue;
return count($iArray);
}
?>
instead, you'll now call :
<?php
array_unshift1 ($a, array (&$v));
?>
for further implications of this rude deprecation, you can read http://masterofweb.com/index.php?itemid=102
(this is not my text)