Thinker
Thinker

Reputation: 2299

Count New Lines in Text File

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

Please help me with this.

Thanks

Upvotes: 2

Views: 3385

Answers (2)

mfonda
mfonda

Reputation: 8003

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

Upvotes: 4

Manish Trivedi
Manish Trivedi

Reputation: 3559

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.

Upvotes: 0

Related Questions