我的代码:
echo "<table width='200px' cellpadding='5' cellspacing='0'><tbody>";
$total = 500;
for ($j = 0; $j < $total;$j++) {
echo "<tr>";
echo "<td>" . ($j+1) . "</td>";
echo "<td>" . get_coupon_code() . "</td>";
echo "</tr>";
}
function get_coupon_code() {
$characters = 'ABCDEFGHJKLMNPQRSTUZWXYZ';
$random_string_length = 8;
$string = '';
for ($i = 0; $i < $random_string_length; $i++) {
$string .= $characters[rand(0, strlen($characters) - 1)];
}
return $string;
}
echo "</tbody></table>";
确保生成的每个代码都是唯一的方法是什么?