On Thu, 10 Aug 2006 17:17:23 -0500, Richard Lynch wrote: > On Tue, August 8, 2006 3:47 pm, Fokkema, I.F.A.C. \(HKG\) wrote: >>>> If the user separates the dates by an enter in the textarea, you >>>> need >>>> to >>>> explode on "\r\n". To be able to handle both, you need to use >>>> split() >>>> or >>>> preg_split(). >>>> >>>> >>>> When I use >>>> $datelist=$_POST[datelist]; >>>> $string=explode('\r\n',$datelist); >>> >>> '\r\n' and "\r\n" are not anything alike... >>> >>> \r\n only have special meaning inside of ", not ' >>> >>> If you want to cover all browser/OS combinations, you'd want to >>> pre-treat the text area input like: >>> $datelist = $_POST['datelist']; >>> $datelist = str_replace("\r\n", "\r", $datelist); >>> $datelist = str_replace("\r", "\n", $datelist); >>> >>> Now all the date are separated by "\n" and you can reliably use >>> explode("\n", $datelist); on them. >> >> Actually, I know that both Windows and Linux send a linebreak in a >> textarea as "\r\n", not "\n". I assume it's all the same for all >> platforms, and that Mac would send "\r\n", too. > > Actually, I know that it's browser/OS dependent, cuz I had a bunch of > Mac users who sent only \r all the time. > > This may be true only of OS 9, and you may not care about them > anymore, but there it is. > > I also would not be so quick to claim that Linux sends \r\n -- It > could be dependent on the browser, the OS version, the OS distro, some > OS settings, ... I've tested this on different distros and browsers, all had sent \r\n and in years I've not had any problems with not receiving \r\n. But I did some extensive searching, and I found this in the W3C specifications: "Line breaks, as in multi-line text field values, are represented as "CR LF" pairs, i.e., `%0D%0A'." (http://www.w3.org/TR/WD-html40-970917/interact/forms.html) > Better safe than sorry, and I *know* I ran into this with some Mac users. > > Plus I hate trying to edit the text chunks in vi with those icky \r > thingies that turn into ^M :-) Well, if it's true that some browsers on some platforms ignore the W3C standard, I guess we could use: $datelist = str_replace(array("\r\n","\n","\r"),'<BR>',$_POST['datelist']); Ivo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php