I've tried this: count new lines in textarea to resize container in PHP?
But it doesn't seems to be working:
$content = nl2br($_POST['text']);
preg_match_all("/(<br>)/", $content, $matches);
echo count($matches[0]) + 1;
It'll always output 1
.
Is there any other solutions to count lines in a string?
` instead? – Marc B Oct 31 '11 at 14:55
` . – Cyclone Oct 31 '11 at 14:56
Firebug doesn't show the actual markup, so don't trust it. – Chris Sobolewski Oct 31 '11 at 15:31