I'm not really sure about what you wanna do? So maybe you can be a little more explicit. However, If you are trying to generate a random array where elements cannot be repeated here is a good algorithm.
Suppose N is the length of your array, what you really want is a permutation of the first N positive integers, do the following:
1- Fill the array such that a(i) = i
2- for i = 1 to n do
j = random(n)