//
you're reading...
PHP

Random Karakter sederhana

kita dapat membuat random karekter dengan menukiskan kode PHP dibawah ini

<?php
srand ((double) microtime() * 10000000);
$input = array ("A", "B", "C", "D", "E","F","G","H","I","J","K","L","M","N","O","P","Q",
"R","S","T","U","V","W","X","Y","Z");
$rand_index = array_rand($input,16);
print $input[$rand_index[3]];
print $input[$rand_index[5]];
print $input[$rand_index[4]];
print $input[$rand_index[2]];
echo " - ";
print $input[$rand_index[1]];
print $input[$rand_index[0]];
print $input[$rand_index[6]];
print $input[$rand_index[7]];
echo " - ";
print $input[$rand_index[8]];
print $input[$rand_index[9]];
print $input[$rand_index[10]];
print $input[$rand_index[11]];
echo " - ";
print $input[$rand_index[12]];
print $input[$rand_index[13]];
print $input[$rand_index[14]];
print $input[$rand_index[15]];

?>

hasilnya seperti ini

SQNU – RZPA – DKHV – JWGM

dan akan selalu berubah apabila browser kita refresh

sederhana kan….

Advertisement

Discussion

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Categories

Follow

Get every new post delivered to your Inbox.