rand(1,N) but excluding array(a,b,c,..),
is there already a built-in function that I don\'t know or do I have to implement it myself(how?)
What you need to do is calculate an array of skipped locations so you can pick a random position in a continuous array of length M = N - #of exceptions and easily map it back to the original array with holes. This will require time and space equal to the skipped array. I don't know php from a hole in the ground so forgive the textual semi-psudo code example.
i elements in the original array.r, in 0..M the number of remaining elements.i such that Offset[i] <= r < Offest[i+i] this is easy with a binary searchr + iNow, that is just a sketch you will need to deal with the ends of the arrays and if things are indexed form 0 or 1 and all that jazz. If you are clever you can actually compute the Offset array on the fly from the original, it is a bit less clear that way though.