Re: [PHP] Unique Identifier String

2002-11-10 Thread @ Edwin
Hello,

"John W. Holmes" <[EMAIL PROTECTED]> wrote:

> What if you create an array of all the letters and numbers, then shuffle
> that array, implode it into a string and grab the first 24 characters?
> It should be fairly random, but not guaranteed unique.

...but just grabbing the first 24 chars wouldn't really give you a
12-letter-12-digit random string, no? I believe he needs the that way...

- E


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Unique Identifier String

2002-11-10 Thread John W. Holmes
What if you create an array of all the letters and numbers, then shuffle
that array, implode it into a string and grab the first 24 characters?
It should be fairly random, but not guaranteed unique. 

---John Holmes...

> -Original Message-
> From: @ Edwin [mailto:copperwalls@;hotmail.com]
> Sent: Sunday, November 10, 2002 6:22 AM
> To: Sebastian A.
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP] Unique Identifier String
> 
> Hello,
> 
> "Sebastian A." <[EMAIL PROTECTED]> wrote:
> 
> > I am currently working on a mySQL site administration system and I
need
> help
> > on figuring out how I can create a 24 digit letter/number unique
> identifier
> > string. I know that I can easily get a random number using a PHP
> function
> (I
> > can remember it off the top of my head) but I also need to create
random
> > letters and then insert them into the number. Here are the steps of
the
> > process:
> >
> > 1. Create a 12 digit random number using a PHP function
> > 2. Create 12 random letters
> > 3. Insert the letters into the number, or the other way around
> > Result: 1h5l79G05OP65kN61LPs1o6Z
> >
> >
> > Out of the steps above, I am not sure how to do 2 and 3 and I would
> greatly
> > appreciate it if someone could point out for me how to do them.
> 
> This may not be the best way but you can do it this way:
> 1. Make sure that the number 1 above is in an array. Then,
> 2. Make an array of uppercase and lowercase letters, shuffle() them.
> 3. Get 12 from each. (i.e. by looping thru each and assigning it to
> another
> array, etc.)
> 4. array_merge() the two resulting arrays.
> 5. shuffle() again.
> 
> Should work...
> 
> - E
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Unique Identifier String

2002-11-10 Thread @ Edwin
And btw, you might want to check "User Contributed Notes" dated 04-Nov-2002
@

  http://www.php.net/manual/en/function.rand.php

Perhaps you can just add some if...else and you can have the
12-random-digit-12-random-letter-string that you're looking for.

HTH,

- E

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Unique Identifier String

2002-11-10 Thread @ Edwin
Hello,

"Sebastian A." <[EMAIL PROTECTED]> wrote:

> I am currently working on a mySQL site administration system and I need
help
> on figuring out how I can create a 24 digit letter/number unique
identifier
> string. I know that I can easily get a random number using a PHP function
(I
> can remember it off the top of my head) but I also need to create random
> letters and then insert them into the number. Here are the steps of the
> process:
>
> 1. Create a 12 digit random number using a PHP function
> 2. Create 12 random letters
> 3. Insert the letters into the number, or the other way around
> Result: 1h5l79G05OP65kN61LPs1o6Z
>
>
> Out of the steps above, I am not sure how to do 2 and 3 and I would
greatly
> appreciate it if someone could point out for me how to do them.

This may not be the best way but you can do it this way:
1. Make sure that the number 1 above is in an array. Then,
2. Make an array of uppercase and lowercase letters, shuffle() them.
3. Get 12 from each. (i.e. by looping thru each and assigning it to another
array, etc.)
4. array_merge() the two resulting arrays.
5. shuffle() again.

Should work...

- E

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Unique Identifier String

2002-11-10 Thread Sebastian A.
I am currently working on a mySQL site administration system and I need help
on figuring out how I can create a 24 digit letter/number unique identifier
string. I know that I can easily get a random number using a PHP function (I
can remember it off the top of my head) but I also need to create random
letters and then insert them into the number. Here are the steps of the
process:

1. Create a 12 digit random number using a PHP function
2. Create 12 random letters
3. Insert the letters into the number, or the other way around
Result: 1h5l79G05OP65kN61LPs1o6Z


Out of the steps above, I am not sure how to do 2 and 3 and I would greatly
appreciate it if someone could point out for me how to do them.





Thanks in advance.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php