Re: [nyphp-talk] generate random unique 8-digit number

2009-03-10 Thread Michael B Allen
On Mon, Mar 9, 2009 at 9:56 PM, chad qian wrote: > Hi, > I need to generate random 8-digit numbers continuously.And no > duplication among all those numbers.In other word,every single 8-digit > number must be unique.How to do php programming? Just to give a little different answer from what peopl

Re: [nyphp-talk] generate random unique 8-digit number

2009-03-10 Thread Artur Marnik
Joey Derrico wrote: One possibility would be to make a DB table with 2 columns. One where each row has a value from through , and the other column marked as for used. When you need to generate the random number you can query the database for each # not currently used and select

Re: [nyphp-talk] generate random unique 8-digit number

2009-03-10 Thread Joey Derrico
One possibility would be to make a DB table with 2 columns. One where each row has a value from through , and the other column marked as for used. When you need to generate the random number you can query the database for each # not currently used and select randomly from the v

Re: [nyphp-talk] generate random unique 8-digit number

2009-03-10 Thread Tim Gales
Chris Snyder wrote: Doing something like $random = $microtime . "_" . rand( 0, 256 ); gives you non-repeating pseudo-randomness. md5(uniqid(rand(), true)) // as suggested in the manual is harder to guess -- but now you're talkin' 32 chars. (as usual it depends on what you're tryin' to do) --

[nyphp-talk] Transforming XML with XSL (XsltProcessor problems)

2009-03-10 Thread Ben Sgro
Hello, My PHP code is: - $xml = new DOMDocument; $xml->load($this->_payload); $xsltProcessor = new XsltProcessor(); $xsl = new DomDocument; $xsl->load('../lib/Transformations/text.xsl'); $xsltProcessor->importStyles

Re: [nyphp-talk] Changing your site look - What is the norm

2009-03-10 Thread Peter Sawczynec
Google. Has undergone numerous updates to their style. Changing the logo, the favicon and adding artwork across the top 2 inches. Google allows users to customize too. Craigslist. Looks dated. Drudgereport. Looks dated. Amazon. Has made many updates to their look. Modernizing buttons,

Re: [nyphp-talk] generate random unique 8-digit number

2009-03-10 Thread Chris Snyder
On Tue, Mar 10, 2009 at 11:54 AM, Dan Cech wrote: > Chris Snyder wrote: >> Add a random number to a sufficiently deep timestamp (microseconds) >> and you will have a non-repeating random number. But you can't shorten >> it to 8 characters or whatever -- you have to keep the full timestamp >> in or

Re: [nyphp-talk] generate random unique 8-digit number

2009-03-10 Thread Rolan Yang
Dan Cech wrote: ... If you're trying to generate relatively short pseudo-random IDs to thwart guesses, then the simplest method is going to be the previously-recommended approach of generating a random number and checking if it has already been used, rinse and repeat until you find one that has

Re: [nyphp-talk] generate random unique 8-digit number

2009-03-10 Thread Edward Potter
Even the numbers game is not random. Some lotto numbers have come up 10X then others. It's the ink on the ball. Shifts the weight. But back to reality, you can get a pretty decent random number, for all practical purposes using the tips covers in this discussion. On Tue, Mar 10, 2009 at 11:54 AM

Re: [nyphp-talk] generate random unique 8-digit number

2009-03-10 Thread Dan Cech
Chris Snyder wrote: > Add a random number to a sufficiently deep timestamp (microseconds) > and you will have a non-repeating random number. But you can't shorten > it to 8 characters or whatever -- you have to keep the full timestamp > in order to maintain non-repeatability. Not really, if you ad

Re: [nyphp-talk] generate random unique 8-digit number

2009-03-10 Thread Chris Snyder
On Tue, Mar 10, 2009 at 11:15 AM, Edward Potter wrote: > > Go down to Prince & Broadway, stop the first model that walks by, then the > next, etc.  Ask them for a random number.  Believe me you will NEVER get the > same number twice. And they will never repeat! All laws of Physics go > straight ou

Re: [nyphp-talk] generate random unique 8-digit number

2009-03-10 Thread Edward Potter
Well, it's easy. Go down to Prince & Broadway, stop the first model that walks by, then the next, etc. Ask them for a random number. Believe me you will NEVER get the same number twice. And they will never repeat! All laws of Physics go straight out the window. Even Einstein gave in. Just my 2

Re: [nyphp-talk] generate random unique 8-digit number

2009-03-10 Thread Fernando Gabrieli
using tim's idea: get a uniqid, convert it to numbers and shift the difference :) - get a uniqid - convert the chars to numbers using php.net/ord - use the 8 first numbers (would be an alternative to rand() for 8-digits) On Tue, Mar 10, 2009 at 9:48 AM, Tim Gales wrote: > chad qian wrote: >

Re: [nyphp-talk] generate random unique 8-digit number

2009-03-10 Thread Tim Gales
chad qian wrote: Hi, I need to generate random 8-digit numbers continuously.And no duplication among all those numbers.In other word,every single 8-digit number must be unique.How to do php programming? Change your specification to 13 characters and use the function uniqid Uniqid is driven by

Re: [nyphp-talk] generate random unique 8-digit number

2009-03-10 Thread Fernando Gabrieli
the easiest: $isInUse = 0 ; while ($isInUse == 0) { $yourNumber = rand(0,9) . rand(0,9) . rand(0,9) (8 times) /* check here if $yourNumber is already in use and save the value in $isInUse */ } without saving the previous you will never be sure if you have duplicates best, fernando On