How do you know how many lines in a post string?

when I post from a textarea, I'd like to know how many lines they are, so I can then begin a for() loop, how do I do a for loop?
LVL 5
eNarcAsked:
Who is Participating?
 
Beverley PortlockConnect With a Mentor Commented:
"lines" in a textarea are normally defined by "\n" characters so you could count them like so

$lines = explode( "\n", $_POST['textAreaName'] );

echo "The number of lines is " . count( $lines );


and process them by

foreach( $lines as $aLine ) {

     // As a demo just echo each line out and put a BR after it
     //
     echo "$aLine<br/>";

}
0
All Courses

From novice to tech pro — start learning today.