Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
[PHP] Random String Generator
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="cxdy" data-source="post: 300102" data-attributes="member: 47821"><p>I made a random string generator in PHP.</p><p>You can use this for things like passwords, file names, etc. Anything you can think of.</p><p>To change the length of the string, edit the 10 in $length on line one.</p><p>Enjoy.</p><p></p><p>The function:</p><p>[PHP]function generateRandomString($length = 10) {</p><p> $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';</p><p> $randomString = '';</p><p> for ($i = 0; $i < $length; $i++) {</p><p> $randomString .= $characters[rand(0, strlen($characters) - 1)];</p><p> }</p><p> return $randomString;</p><p>}[/PHP]</p><p>Then, if you ever want to call it,</p><p>[PHP]echo generateRandomString();[/PHP]</p></blockquote><p></p>
[QUOTE="cxdy, post: 300102, member: 47821"] I made a random string generator in PHP. You can use this for things like passwords, file names, etc. Anything you can think of. To change the length of the string, edit the 10 in $length on line one. Enjoy. The function: [PHP]function generateRandomString($length = 10) { $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $randomString = ''; for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, strlen($characters) - 1)]; } return $randomString; }[/PHP] Then, if you ever want to call it, [PHP]echo generateRandomString();[/PHP] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
[PHP] Random String Generator
Top