How to use data line by line with loop

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Real Hyder
    New Member
    • Mar 2012
    • 1

    How to use data line by line with loop

    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.
  • PsychoCoder
    Recognized Expert Contributor
    • Jul 2010
    • 465

    #2
    You could use something like this, using trim, explode and array_filter

    Code:
    function getLines(){
    	$str = trim($_POST['TextArea1']);
    	$textArrray = explode("\n", $str);
    	$textArrray = array_filter($str, 'trim'); // remove any extra \r characters left behind
    
    	foreach ($textArrray as $line) {
    		// processing here. 
    	}
    }

    Comment

    • Bharat383
      New Member
      • Aug 2011
      • 93

      #3
      use nl2br($row['address']);

      Comment

      Working...