note 21096 deleted from function.array-splice by kennyt

From: Date: Mon, 05 Jan 2004 02:43:29 +0000
Subject: note 21096 deleted from function.array-splice by kennyt
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-62928@lists.php.net to get a copy of this message
Note Submitter: amtiee@hotmail.com ---- array_splice() sometimes seems to be worth nothing, since it asks for the offset of a key from where to start splicing ... Here is a fuction that dosent need you to speciy array offset. function my_array_splice($aArray,$szKey, $iLength) { $aKeys = array_keys($aArray); $iIndex = array_search($szKey, $aKeys); array_splice($aArray, $iIndex, 1); } Call it passing a refernce of array to be spliced ... my_array_splice(&$aToSpliceArray, $szSpliceFrom, $iSpliceTill); The above function can be modified/generalized completely to take all the parameters accepted by array_splice().

« previous php.notes (#62928) next »