Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating a random numbers and letters

Tags:

php

Can I ask for a certain code on how to generate a random letters and numbers in one word. I know there's a PHP function rand(), but I don't know if it's also applicable with letters. There's also a function called mt_rand() but I don't know how it works. I'm planning on generating a word like this one:

$randomcode = re784dfg7ert7;

Do you guys have any simple code on this one? Thanks in advance!

like image 225
glove Avatar asked Sep 06 '11 15:09

glove


1 Answers

echo bin2hex(openssl_random_pseudo_bytes(12));
like image 198
dervil Avatar answered Oct 22 '22 17:10

dervil