how to count new lines in a very big string? March 29, 2023 by Tarik substr_count should do the trick: substr_count( $your_string, "\n" );