note 37291 added to function.array-unshift

From: Date: Sun, 09 Nov 2003 09:46:18 +0000
Subject: note 37291 added to function.array-unshift
Groups: php.notes 
Request: Send a blank email to php-notes+get-60156@lists.php.net to get a copy of this message
Last version of PHP deprecated unshifting of a reference. You can use this function instead : function array_unshift1 (& $ioArray, $iValueWrappedInAnArray) { $lNewArray = false; foreach (array_keys ($ioArray) as $lKey) $lNewArray[$lKey+1] = & $ioArray[$lKey]; $ioArray = array (& $iValueWrappedInAnArray[0]); if ($lNewArray) foreach (array_keys ($lNewArray) as $lKey) $ioArray[] = & $lNewArray[$lKey]; return count($ioArray); } // before last PHP (now generates a deprecation warning) array_unshift ($a, &$v); // since last PHP (caution, there is a wrapping array !!) array_unshift1 ($a, array (&$v)); ---- Manual Page -- http://www.php.net/manual/en/function.array-unshift.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+37291 Delete -- http://master.php.net/manage/user-notes.php?action=delete+37291&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+37291&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#60156) next »