• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 139
  • Last Modified:

removing an item from an array

How do you remove an item from an array?

0
weikelbob
Asked:
weikelbob
1 Solution
 
dr_dedoCommented:
<?
$d = array(1,5,6,8,9,33,44,66);
print_r($d);

array_splice($d, 2 , 3); //remove elements from position 2and delete 3 elements. it re-arranges the array, if u ommit the length to delete (3 in our example), it will delete from position 2 to the end of the array
print_r($d);

?>

you can use
unset($d[2]) to remove item with index 2, but the deleted item will leave a vacant place
0
 
weikelbobAuthor Commented:
Got this, thanks dr. dedo
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now