随机读取txt每行的内容

<?php
// 读取文件内容到数组
$contentArr = file('filename');
//总行数
$totleLines count($contentArr);
//随机行数
$current = rand(1, $totleLines);
//随机的内容输出
echo "<td><a href=\"$contentArr[$current]\">$contentArr[$current]</a></td>";
?>
 
posted @ 2012-12-10 09:36  stma  阅读(162)  评论(0)    收藏  举报