Do you have a design for what you are trying to do. You've been fussing with ways to code this and that and I'm not sure what it is you are trying to do.
Perhaps arrays are not the right container to hold your values. There are collection/container classes that allow you to save values and to test if the value is already in the container.