A couple of ideas to improve the chances of generating unique strings
You could create 20,000,001 char(6) strings, merge the first with the
last, second with the second last and so on, creating char(12) strings
or
You could create 20,000,001 char(7) strings, merge the first with the
last, second with the second last and so on, creating char(14) strings
and then dropping two digits at random.
BUT if you must guarantee that the strings are unique then you will need
to do a comparison of the resulting strings. Using a database to sort
and then compare is as good an approach as any, since database have good
sorting algorithms and are designed to manage large numbers.
graeme.
bo wrote:
I need to generate 10million 12-char string and I am able to do so, however
the problem is how to avoid repetition keeping each string unique? it will
be a disaster to compare each string,isn't it?
ps Thanks Yong.
Bo
--
Experience is a good teacher, but she sends in terrific bills.
Minna Antrim
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php