On Tue, 2003-12-02 at 18:33, Richard Davey wrote: > Hello Daniel, > > Tuesday, December 2, 2003, 10:46:33 PM, you wrote: > > dh> For generation of a random string with length 1.000.000 it takes about > dh> 13 seconds on my xp 1600+.. that's quite a lot, imho, so suggestions > dh> are very welcome.. >
I missed the original post, and I'm too lazy to go looking, but the following code runs in approx. 2.75 seconds on my Athlon 2400 running linux: $chars = '0123456789' .'abcdefghijklmnopqrstuvwxyz' .'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; $charArray = array(); for( $i = 0; $i < 1000000; $i++ ) { $charArray[] = $chars[rand( 0, 61 )]; } It's runs much faster than using a .= style of string creation. Cheers, Rob. -- .------------------------------------------------------------. | InterJinn Application Framework - http://www.interjinn.com | :------------------------------------------------------------: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `------------------------------------------------------------' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php