Re: replace %rand[x]-[y]% macro in string with random string

From: Date: Wed, 03 Dec 2003 00:26:29 +0000
Subject: Re: replace %rand[x]-[y]% macro in string with random string
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-171617@lists.php.net to get a copy of this message
on 02 Dec 2003 18:56:28 -0500 Robert Cummings wrote: RC> I missed the original post, and I'm too lazy to go looking, but the RC> following code runs in approx. 2.75 seconds on my Athlon 2400 running RC> linux: it is 4.3 seconds on xp 1600+.. RC> $chars = '0123456789' RC> .'abcdefghijklmnopqrstuvwxyz' RC> .'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; RC> $charArray = array(); RC> for( $i = 0; $i < 1000000; $i++ ) RC> { RC> $charArray[] = $chars[rand( 0, 61 )]; RC> } RC> It's runs much faster than using a .= style of string creation. ..and replacing "$charArray[] =" with "$s .=" crawls this down to 3.5 seconds - so this is faster here.. winxp, php 4.3.4, Apache 1.xx -- shinE! http://www.thequod.de ICQ#152282665 PGP 8.0 key: http://thequod.de/danielhahler.asc

« previous php.general (#171617) next »