The first technic would be to generated a random number, look for an array to see if it has already been generated, and continue like that.
But a better method would be to generate an array of 20 (with the number from 1 to 20) and shuffle the array (you know, swap elements) a X number of times, and after just take the number from indice 0 to 5, look at this example:
Bookmarks