PHP脚本-向$fcontents中添加一个随机数组


PHP Script - Adding a randomizing array to $fcontents which goes sequentially?

试图使这个脚本随机。我尝试了这个字符串的变化$banner_no = rand(1,$max)-1;

<div id="header_banner_ad">
    <?php
        $fcontents = join ('', file ('FILENAME'));
        $s_con = split("~",$fcontents);
        $banner_no = rand(1,(count($s_con)-1));
        echo $s_con[$banner_no];
    ?>
</div>

我不知道该怎么做。

如果你不想从数组中选择一个随机元素,你可以使用array_rand()

的例子:

$random = array_rand($s_con);
echo $s_con[$random];