in reply to Testing if an array contains a value and then deleting it in most efficient way

I'll put in another vote for "use a hash instead of an array" unless there's some reason that the order of the values needs to be preserved.

If the order that you'll need the values is predictable, you may also be able to have the database pre-sort them for you so that you can just shift values out of the array. One sort will almost always be faster than 10,000 searches. (Especially since those searches will have to be done in extremely-ineffecient ways unless the data is sorted first...)

  • Comment on Re: Testing if an array contains a value and then deleting it in most efficient way