从php中的txt文件中随机旋转文本

问题描述 投票:0回答:1

我想从txt文件中旋转文本

这是我的下面的代码,但它不工作,我不知道我在哪里弄错了

 <?php
$text= file_get_contents("text.txt");

$arr = explode("\n", $text);

$max = count($arr);

$i = 0;
while($i < 3)
{
     $i++;
     echo $aText[rand(0, $arr)];
?> 

在我的text.txt文件中,我有一些文字

are
can
how
now
put
see

我想逐行排除,但它无法正常工作。请帮帮我。

php file-get-contents
1个回答
0
投票
     <?php


    $arr =   explode("\n", file_get_contents('text.txt'));


     foreach($arr as $key =>$value)
      {
        echo $value;//Prints the file content
      }

    ?> 
© www.soinside.com 2019 - 2024. All rights reserved.