By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,826 Members | 2,443 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,826 IT Pros & Developers. It's quick & easy.

How to use data line by line with loop

P: 1
I have to get data from from is "text area". Data in each line.

Then use data line by line using 'for' loop. or other do while if you suggest.


What should I do to split it into lines then use every line.

For example

for (aaaa; aa<aa; aa++)
{

}


Hope I defined : ( Please help me. Thanks.
Mar 4 '12 #1
Share this Question
Share on Google+
2 Replies


PsychoCoder
Expert Mod 100+
P: 465
You could use something like this, using trim, explode and array_filter

Expand|Select|Wrap|Line Numbers
  1. function getLines(){
  2.     $str = trim($_POST['TextArea1']);
  3.     $textArrray = explode("\n", $str);
  4.     $textArrray = array_filter($str, 'trim'); // remove any extra \r characters left behind
  5.  
  6.     foreach ($textArrray as $line) {
  7.         // processing here. 
  8.     }
  9. }
Mar 4 '12 #2

P: 93
use nl2br($row['address']);
Apr 16 '12 #3

Post your reply

Sign in to post your reply or Sign up for a free account.