Count New Lines in Text File

守給你的承諾、 提交于 2019-12-11 02:07:26

问题


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

Please help me with this.

Thanks


回答1:


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.

For example:

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



回答2:


You can perform this task by key-events. I think php don't have any key event, so you can use any scripting language like java-script that have key events.



来源:https://stackoverflow.com/questions/4731838/count-new-lines-in-text-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!