08/08/30 01:23:35
ちなみにrandom.phpは検索で拾ったソースです。
↓
<?php
// hitには相対確率を入れる。完全にランダムにするなら全部"1"にする
// rtxtには、テキストを入れる。改行はしないようにする
// テキストを増やしたりする場合は、"[ ]"の数字が0から順になるようにする
$hit[0] = 1; $rtxt[0] = '<a href="...">1</a>';
$hit[1] = 1; $rtxt[1] = '<a href="...">2</a>';
$hit[2] = 1; $rtxt[2] = ''<a href="...">3</a>';
$length = count($hit) - 1;
for($i=0; $i<=$length; $i++) {
$m += $hit[$i];
}
srand( (double)microtime()*1000000 );
$n = round(rand(1,$m) );
for($i=0; $i<=$length; $i++) {
$x = $y;
$y += $hit[$i];
if($x<$n && $n<=$y) $ad = $rtxt[$i];
}
print("$ad");
?>
よろしくお願いします。