Re: Re: help with end of line charater

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Shawn McKenzie wrote:
This may be best handled in your sorting code.  What does it look like?

yeah just a second ago a big lightbulb went off in my head and i fixed my code to add a \r\n on saving, and strip it on viewing. I sort on viewing, not sort on saving. The viewing code looks like:

$biglist = "";

$filename = "/usr/local/majordomo/lists/".$edit;

$fp = fopen($filename, "r") or die ("Couldn't open $filename");
if ($fp)
       {
       while (!feof($fp))
               {
               $thedata = fgets($fp);
               $buildingvar[] = $thedata;
               }
                       sort($buildingvar);
                       foreach ($buildingvar as $key => $val)
                               {
if ($val != "\r\n") //gets rid of empty whitespace lines
                                       {
                                       $biglist .= "$val";
                                       }

                               }

       }

//$biglist gets echo'd into a textarea box below.

but now right before it is saved, i'll add a new line

$list .="\r\n";

$fp = fopen($filename, "w") or die ("Couldn't open $filename");
if ($fp)
       {
       fwrite($fp, $list);
       echo "
       <head><title>Saving Page</title>
       <link rel=stylesheet href=/maillist.css type=\"text/css\">
       </head>
       Your mailing list has been updated.";
       }

fclose($fp);

so that upon viewing, if they didn't press enter, a \r\n will be added, and even if they did add press enter on the last line, it'll be stripped out upon viewing the list of email addresses.



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux