计算文本文件中的新行 [英] Count New Lines in Text File

查看:66
本文介绍了计算文本文件中的新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想计算使用PHP在文本文件中输入shift +的次数。

I would like to count the number of shift+enters in a text file using PHP.

请帮助我。

感谢

推荐答案

假设你只是意思是\r\\\
(回车+换行),函数 substr_count file_get_contents 应该做的。

Assuming you just mean "\r\n" (carriage-return + line feed) by this, the function substr_count in conjunction with file_get_contents should do the trick.

例如:

$count = substr_count(file_get_contents($filename), "\r\n");

这篇关于计算文本文件中的新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆