Archive

Posts Tagged ‘explode string’

Counting the number lines in a string – 2 Solution

February 20th, 2009 No comments
Counting the number lines in a string – 2 Solution Counting the number lines in a string with explode function: <?php $lines = explode("\n", $string); $nr_lines = count($lines)-1; ?> Counting the number lines in a string with  substr_count function: <?php $nr_lines = substr_count($string,"\n"); ?> the 2'nd solution is better.
GoCache - ByREV-Cache v1.0 - live served in : 0.393961 sec (gzip)