with this script we can make random without duplicate. We use function shuffle to random array.
then looping that array to get random as much as we want.
<?php
$array_word=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');
shuffle($array_word);
reset($array_word);
$no=0;
foreach($array_word as $line)
{
$random.=strtoupper($line);
$no++;
if ($no >= 6) break;
}
echo $random;
?>
$array_word=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');
shuffle($array_word);
reset($array_word);
$no=0;
foreach($array_word as $line)
{
$random.=strtoupper($line);
$no++;
if ($no >= 6) break;
}
echo $random;
?>





0 komentar:
Post a Comment