Showing posts with label rand. Show all posts
Showing posts with label rand. Show all posts

Sunday, December 14, 2014

Create Random Code with rand

<?php
$batch_code = 'DROID';
$characters = range('0','3');
for ($i = 0; $i < 4; $i++) {
$rand = mt_rand(0, count($characters)-1);
$batch_code .= $characters[$rand];
}
echo $batch_code
?>

Answer
DROID2130

***************************************

Create Random Number
<?php
echo "DU".substr(md5(uniqid(mt_rand(), true)), 0, 3);
?>

Answer
DU4e1