hlstriker Posted April 26, 2007 Share Posted April 26, 2007 Hi, can someone tell me how to generate about 8-10 chars worth of random gibberish and add it to a string please? Example: string = coolname; gibberish = generating(gibberish!); newstring = string . gibberish; I really don't know how to generate the gibberish so I just made it up in that example. Link to comment https://forums.phpfreaks.com/topic/48731-generating-random-gibberish/ Share on other sites More sharing options...
LazyJones Posted April 26, 2007 Share Posted April 26, 2007 So many nifty solutions for this one, here's one http://www.tutorialized.com/tutorial/PHP-Random-String-Generator/13903 *couch*google*couch* Link to comment https://forums.phpfreaks.com/topic/48731-generating-random-gibberish/#findComment-238858 Share on other sites More sharing options...
Barand Posted April 26, 2007 Share Posted April 26, 2007 or if you just want a-z A-Z, <?php function gibberish($size) { $base = array_merge(range('a','z'), range('A','Z')); shuffle($base); return join('', array_slice($base, 0, $size)); } echo gibberish(; ?> Link to comment https://forums.phpfreaks.com/topic/48731-generating-random-gibberish/#findComment-238905 Share on other sites More sharing options...
taith Posted April 26, 2007 Share Posted April 26, 2007 <? function randomkeys($length){ $pattern = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; for($i=0;$i<$length;$i++) $key .= $pattern{rand(0,62)}; return $key; } ?> Link to comment https://forums.phpfreaks.com/topic/48731-generating-random-gibberish/#findComment-238917 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.