Forum Moderators: coopster

Message Too Old, No Replies

How to create rand() char

Turning random integer into character

         

twist

5:45 pm on Mar 19, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



After searching through php.net, webmasterworld and the web looking for a quick easy way to convert a random number into a single character.

I came up with this solution and am curious of any drawbacks or problems that this could cause or if their is a better method available.

echo chr( rand(97, 122) ); // returns a-z
echo chr( rand(65, 90) ); // returns A-Z

jatar_k

10:26 pm on Mar 21, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Seems like a fine answer to me twist.