2

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

Please help me with this.

Thanks

Jonah
  • 9,991
  • 5
  • 45
  • 79
Thinker
  • 2,253
  • 6
  • 23
  • 23

2 Answers2

4

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");
mfonda
  • 7,873
  • 1
  • 26
  • 30
  • COunting just "\n" will support mac, linux and windows files which may not all use returns (\r) – Eddie Nov 08 '13 at 00:09
0

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.

Manish Trivedi
  • 3,481
  • 5
  • 23
  • 29