array_reverse() 期望参数 1 为数组,字符串给出
我正在抓取一个 .txt 文件并尝试反转它,但是当我尝试时出现此错误,我不明白它。请帮忙?
array_reverse() 期望参数 1 为 是数组,字符串给出......
下面是代码:
$dirCont = file_get_contents($dir, NULL, NULL, $sPoint, 10240000);
$invertedLines = array_reverse($dirCont);
echo $invertedLines;
I am grabbing a .txt file and trying to reverse it, but I get this error when I try to, I don't understand it. Help please?
array_reverse() expects parameter 1 to
be array, string given in ......
Here is the code:
$dirCont = file_get_contents($dir, NULL, NULL, $sPoint, 10240000);
$invertedLines = array_reverse($dirCont);
echo $invertedLines;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
字符串不是数组吗?即使它是(如在 C 字符串中),它也不会按您的预期工作。您需要在换行符处拆分文件(如果您尝试反转以首先获取文件末尾)。
A string is not an array? Even if it were (as in C strings) it would not work as you expected. You'll need to split the file on line breaks (if you're trying to reverse to get the end of the file first).
我认为你需要传递数组上的值。
这对我来说效果很好。
I think you need to pass the value on an array.
This is working fine for me.