小编use*_*811的帖子

在php中获取文本文件的前3行

我正在用PHP开发一个网站,我必须在索引中包含PHP中文本文件的前3行.我怎样才能做到这一点?

<?php
$file = file_get_contents("text.txt");
//echo the first 3 lines, but it's wrong
echo $file;
?>
Run Code Online (Sandbox Code Playgroud)

php text lines

0
推荐指数
3
解决办法
5193
查看次数

标签 统计

lines ×1

php ×1

text ×1