如何让这个随机字符串生成器创建随机字符串。我不断重复。阵列通常由 0 到 10 个东西组成,但它仍然在重复获得相同数量的床和浴室,我知道从统计学上讲它是一团糟。
我怎样才能消除重复?
for ($i = 0; $i <= 1000000; $i++) {
srand($i);
$price = rand(20000, 1000000);
$bed = rand(0, 20);
$bath = rand(0, 7);
$addressnum = rand(100, 10000);
$address = (int) preg_replace('/\D/', '', $addressnum) . " lol st";
$province = $f_contents[rand(0, count($f_contents) - 1)];
$postedby = 3;
$description = $de_contents[rand(0,count($de_contents) - 1)];
$status = "Unsold";
$type = $status_a[array_rand($status_a)];
$category = $category_type[array_rand($category_type)];
$size = rand(100,100000);
$builtin = rand(1850, 2013);
$queryString = "INSERT INTO listings
(PRICE, ADDRESS, PROVINCE, DESCRIPTION, STATUS, TYPE, CATEGORY, SIZE, BUILTIN, BED, BATH, POSTED_BY) VALUES
($price, '$address', '$province', '$description', '$status', '$type', '$category', $size, $builtin, $bed, $bath, $postedby)";
echo $queryString . "<br>";
$query = $db -> query($queryString);
}