[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2011-03-15
2
Medium Priority
?
282 Views
Last Modified: 2012-06-21
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?
0
Comment
Question by:eNarc
2 Comments
 
LVL 40

Assisted Solution

by:Gurvinder Pal Singh
Gurvinder Pal Singh earned 1000 total points
ID: 35137701
0
 
LVL 34

Accepted Solution

by:
Beverley Portlock earned 1000 total points
ID: 35137718
"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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Find out what you should include to make the best professional email signature for your organization.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Suggested Courses
Course of the Month18 days, 18 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question