php functions
Posted in
9058
5:04 am, October 23, 2021
generate random username function in php
a function that takes several random words and creates a user name from them. This will generate a user name with between one to three words and a prefix if prefix_show
is set to true.
usage
generate_username($prefix_show = true);
assign to variable
$user_name = generate_username($prefix_show = true);
echo the user name
echo generate_username($prefix_show = true);
PHP
function generate_username($prefix_show = true) {
$usernames = "gang synonymous bumper return mar flint dove slimping wimp collop rich sardent irritating ponder bumble bee fly mongoose bitter syllable zonked functional sled monk educate raging tyres crow cruel godly fizzle reprimand hand ball cheery arrest flower gristly mitt chicken tidingskates aptbare pedlarplastic chew slurp cumbersome researcher fumbling booze slice warming unpopular tuna vocal dream flap jack mold warp hideous prepare immediate trip wire duster burning lay cotton thin antelope igloo crow supset morning bind chopping stutter hilarious victorious found moan ox surferread adoring gas bag unknown smell skating walking jumper live pole puppy resolute hide offer pale care shady beaver avocet twist woozy flush aged labourer washing worship puck ragged tart torn diced peg gang synonymous bumper return mar flint dove slimping wimp collop rich sardent irritating ponder bumble bee fly mongoose bitter syllable zonked functional sled monk educate raging tyres crow cruel godly fizzle reprimand hand ball cheery arrest flower gristly mitt chicken tidingskates aptbare pedlarplastic chew slurp cumbersome researcher fumbling booze slice warming unpopular tuna vocal dream flap jack mold warp hideous prepare immediate trip wire duster lay cotton thin antelope igloo crow supset morning bind chopping stutter hilarious victorious found moan ox surferread adoring gas bag unknown smell skating walking jumper live pole puppy resolute hide offer pale care shady beaver avocet twist woozy flush sucked aged labourer washing worship puck ragged tart torn diced peg enchanting satisfying honky reflecting shears slimeball ladder cauldron emerald potatoes tnt stick clay cyandye furnace lever sugar flint bookshelf signpost rails dirt jukebox torch map charcoal lava fire ice leather apple clock wheat saddle coalore sign carrots lilypad anvil air birchwood catdisc egg melon bedrock fern sponge sandstone sulphur bonemeal vines string sand gravel lilypad emerald cauldron air sandstone coalore bonemeal dandelion catdisc portal sand shears sponge vines clock wheat map gravel tripwire dispenser fern saddle furnace bow anvil trapdoor torch fire dirt ladder redstone blazerod carrots melon obsidian jukebox bedrock sulphur cyandye slimeball sugarcane snowball potatoes stick rails flowerpot flint charcoal egg lava catdisc stick bedrock rails map fire birchwood trapdoor leather charcoal potatoes melon coalore bookshelf obsidian furnace saddle ice cyandye cauldron dirt flint string emerald portal mycelium potato anvil flowerpot sign torch bow minecart jukebox fern sandstone redstone sponge lever shears dispenser dandelion sulphur ladder sugarcane carrots blazerod slimeball sugar tnt rake glaring business bloat bouquet goring smack gulp team cluster grist tittering commotion panel labour rope staff banner sdraught lead army worship husk gam bike parliament linkage moulting fold trembling brood orchestra breakdown bind parade promise shoal troupe kettle subtlety pod wilderness leap culture remuda sault harem building drove cache trip whiteness rag fluther coffle choir kindle balance shrewdness bavin nest wealth cache grist slate annoyance belt fraid sute audience safe rope puddling den anthology tabernacle labour cartload pray erst exaltation descent cletch sedge skulk harras farrow chirm dule compromise library husk cadge cohort coven shoal committee team eyrar lollies gatorade apricots sausage oil pie apples venison orange lard relish chowder garlic basmati pepperoni jerky granola doughnut vegetables syrup caviar tacos polenta pudding quiche sardines cordial icecream eggs milkshakes rice pepper pretzels oatmeal truffle mayonnaise paella clam salami chile salt tomatoe crackers pistachio burritos muesli coconut abalone raisins bagels opossum dingo ocelot ibis caribou sheep mussel rhino snail flyingfish raven elephant oyster ox hound walrus horse dunnock spoonbill stork peregrine crane auk eland buck gelding meerkat lizard kangaroo smelt orangutan lark hyena cattle cockroach mackerel cobra ponie rattlesnake quail penguin ptarmigan shrimp moth goose prairiedog cormorant lice cranky possessive gratified gleeful peaceful mild burning";
$usernames = explode(" ", $usernames);
$prefixes = "boss mad vip pwn dr slayer cool bad good scared frozen cold hot old new fresh dark fast spicy scary santa epic"; // mr mrs miss
$prefixes = explode(" ", $prefixes);
$prefix = $prefixes[array_rand($prefixes)];
$loop = rand(0,2);
$max = count($usernames);
$max = $max - 1;
$i = 0;
$ruser = "";
while ($i <= $loop) {
shuffle($usernames);
$una = rand(0,$max);
if ( ($i == 0) && ($prefix_show === true) ) {
$ruser .= "[".ucfirst($prefix)."] ";
}
$ruser .= ucfirst($usernames[$una]) . " ";
$i++;
}
return trim($ruser);
/*
shuffle($usernames);
$ruser = ucfirst($usernames[$una[0]]) . " ";
return $ruser .= ucfirst($usernames[$una[1]]);
*/
}
echo "<h3>user name with prefix</h3>";
echo generate_username($prefix_show = true);
echo "<br>";
echo "<h3>user name with no prefix</h3>";
echo generate_username($prefix_show = false);
View Statistics
This Week
293
This Month
1192
This Year
2502
Add Comment
Other Items in php functions
show views list function
list page links function list_page_links
Return a file extention from a string
shorten string php, string length php, clip string length php
get file name from path name in php
imgur upload from php
simplepie error : XML or PCRE extensions not loaded!
loading a non processed item using the load_from_fields_array function
simple file cache and check in php
loop through $_GET in php
php strip non numbers from string - remove all non-numeric characters from a string
get string between other strings function php
php validate email function
convert a string into its html entitles using php htmlentities function
make a nice readable date using a timestamp string function make_nice_date
get php to validate its self with php check syntax
Spam IP Database and delete button
youtube search api request function
list all array json function list_all_array_json
php get file extension from a file name
php post data back to a url with a function
generate random username function in php
Related Search Terms
Other Categories in Code
alpine js apps c css factorio font awesome images linux quick modals sqlite site bugs site updates slick slider sliders testing windows apps apache api apps asp bat bootstrap bootstrap templates charts cookies core css css filters css grid design elements docker domains emoji fancybox fonts foundation framework gimp git html icons ideas image formatting images javascript javascript functions jquery js linux mac misc modals mysql nginx node php php errors php function php functions php simple html dom pi400 python react regex sections simple_html_dom simplepie php site bugs site documentation slick slider sql sqlite ssh sublime svg svg css templates tools virtual box vscode vue webdev windows windows 11 windows commands wordpress