Welcome Guest, Not a member yet? Register   Sign In
How to generate a random serial number
#10

[eluser]jedd[/eluser]
There are two things generally troublesome with rand style functions - they are computationally expensive, and they are seldom random. Wink

The pattern problem I refer to was generating a number in the same fumction that you want to test uniqueness in - it's doable, but not very elegant. My first paragraph, and the subsequent two posts from other people, explained the benefit of having the generate function external. That you asked, indicates you also worked out that it's a problem to do both things in one function.

As to expense - I am a week away from access to a computer (on my phone at the moment) so I can't test performance, but my gut feel is that a php function you write that relies upon rand() will not beat a C library deterministic function. I may, of course, be wrong. It's easy enough to test if you're curious, but be sure to use a big sample set.

And, as I say, integers are preferable for a couple of reasons, if you can use them instead.


Messages In This Thread
How to generate a random serial number - by El Forum - 12-25-2010, 06:34 PM
How to generate a random serial number - by El Forum - 12-25-2010, 08:40 PM
How to generate a random serial number - by El Forum - 12-25-2010, 10:21 PM
How to generate a random serial number - by El Forum - 12-26-2010, 07:00 AM
How to generate a random serial number - by El Forum - 12-27-2010, 05:10 AM
How to generate a random serial number - by El Forum - 12-27-2010, 07:23 AM
How to generate a random serial number - by El Forum - 12-27-2010, 07:34 AM
How to generate a random serial number - by El Forum - 12-27-2010, 02:25 PM
How to generate a random serial number - by El Forum - 12-27-2010, 02:32 PM
How to generate a random serial number - by El Forum - 12-27-2010, 04:56 PM



Theme © iAndrew 2016 - Forum software by © MyBB