note 27045 added to function.array-splice
| From: | satan at bizmedia dot pl | Date: | Thu, 21 Nov 2002 11:01:44 +0000 |
| Subject: | note 27045 added to function.array-splice | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-39793@lists.php.net to get a copy of this message | ||
Simple function to remove item from an array:
function RemoveArrayItem(&$ar,$n)
{
$ar = array_merge(array_splice($ar,0,$n),array_splice($ar,1));
}
example:
$arr=array(1,2,3,4,5,6,7,8,9);
RemoveArrayItem($arr,5);
# it will remove te 5 index that points to number 6
output array:
1,2,3,4,5,7,8,9
# SaTan #####
--
http://www.php.net/manual/en/function.array-splice.php
http://master.php.net/manage/user-notes.php?action=edit+27045
http://master.php.net/manage/user-notes.php?action=delete+27045
http://master.php.net/manage/user-notes.php?action=reject+27045