开发者

Count New Lines in Text File

开发者 https://www.devze.com 2023-02-05 15:54 出处:网络
I would like to count the number of shift+enters in a text 开发者_StackOverflowfile using PHP. Please help me with this.

I would like to count the number of shift+enters in a text 开发者_StackOverflowfile using PHP.

Please help me with this.

Thanks


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");


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消