note 37278 added to function.array-unshift

From: Date: Sat, 08 Nov 2003 14:32:52 +0000
Subject: note 37278 added to function.array-unshift
Groups: php.notes 
Request: Send a blank email to php-notes+get-60141@lists.php.net to get a copy of this message
Since deprecation of call-time pass-by-reference, you can not unshift with a reference : array_unshift ($a, &$v); If you'd like to unshift only one reference, here is a replacement function : 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 : 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) ---- Manual Page -- http://www.php.net/manual/en/function.array-unshift.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+37278 Delete -- http://master.php.net/manage/user-notes.php?action=delete+37278&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+37278&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#60141) next »