Re: Re: help with end of line charater

From: Date: Fri, 30 Jan 2009 17:44:51 +0000
Subject: Re: Re: help with end of line charater
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-287433@lists.php.net to get a copy of this message
Hello Adam! $list2 = explode("\n", $list); // "\n" not "\r\n" $list = implode("\r\n", $list2); foreach ... - not need with the best regards - Konstantin Kurilov Shawn McKenzie wrote:
Adam Williams wrote:
I have staff inputting email addresses into a <textarea> named $list on a form and when they click submit, my php script sorts the email addresses and writes to disk. The problem is, lets say they enter the email addresses bob@mdah.state.ms.us<staff hits enter> amanda@mdah.state.ms.us<staff hits enter> sally@mdah.state.ms.us<staff hits enter> joe@mdah.state.ms.us<staff hits enter> cindy@mdah.state.ms.us<staff does not hit enter and clicks on submit button> then views the sortes email addresses, it displays as: amanda@mdah.state.ms.us bob@mdah.state.ms.us cindy@mdah.state.ms.usjoe@mdah.state.ms.us sally@mdah.state.ms.us because the staff didn't hit enter on the last line. Is there a way to read each line of input and add a carriage return if needed? I tried the code below but it did not work, nothing happened, and i don't know to examine each line to see if it ends in \r\n either. $list2 = explode("\r\n", $list); foreach ($list2 as $key => $var)
      {
      $var = $var."\r\n";
      }
$list = implode("\r\n", $list2);
This may be best handled in your sorting code. What does it look like?


« previous php.general (#287433) next »