note 21096 added to function.array-splice
| From: | amtiee at hotmail dot com | Date: | Mon, 29 Apr 2002 07:35:51 +0000 |
| Subject: | note 21096 added to function.array-splice | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-29966@lists.php.net to get a copy of this message | ||
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().
--
http://www.php.net/manual/en/function.array-splice.php
http://master.php.net/manage/user-notes.php?action=edit+21096
http://master.php.net/manage/user-notes.php?action=delete+21096
http://master.php.net/manage/user-notes.php?action=reject+21096