gpt4 book ai didi

php - 将 .txt 文件的最后 25 行发布到网站?

转载 作者:搜寻专家 更新时间:2023-10-30 20:21:03 25 4
gpt4 key购买 nike

我有一个将输入的文本行上传到 .txt 文件的表单,我想在带有文本输入表单的页面上显示文本文件的最后 25 行(我还想给每一行1-800px 之间的随机左边距值)- 我怎样才能实现它?

最佳答案

我想你会想看看file() , array_slice() , 和 rand() .

也许是这样的:

$output = "";
$lines = array_slice(file("test.txt"), -25, 25);

foreach ( $lines as $line )
{
$output .= '<div style="margin-left: ' . rand(1, 800) . 'px;">' . $line . '</div>';
}

echo $output;

关于php - 将 .txt 文件的最后 25 行发布到网站?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5971387/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com