Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

array item removal

Status
Not open for further replies.

rbehler

Programmer
Apr 9, 2002
1
US
can someone tell me how i can remove an item from an array? say i have an array of 25 items. I want to remove item 20 from the array. now i have 24 items in the array. I want to remove an item but keep the other items in the array.
 
There are several ways to do it. But first question: does the order matter? You only said you wanted to keep the others in the array, you didn't say you wanted to keep the order. If order don't matter, you can just replace item 20 with item 24 (assuming you start numbering from zero...), then erase item 24. If order matters, you need to move item 21 to 24 into items 20 to 23.

In a REAL database program, you might want to use an index to keep track of the proper order of the items in the array, then simply put the last item in the array into any deleted items. "Information has a tendency to be free. Which means someone will always tell you something you don't want to know."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top