Re: line breaks
| From: | John Nichel | Date: | Tue, 25 Nov 2003 14:30:53 +0000 |
| Subject: | Re: line breaks | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-170885@lists.php.net to get a copy of this message | ||
Rodney Green wrote:
Greetings! I'm writing a script that will take the contents of a text file that has several lines of user accounts and creates a shell script with chown commands for each user in that text file. My problem is that when it writes the shell script file it puts a line break after the colon in between $buffer and html. How do I prevent this from doing that? Thanks, Rod Code: ----------------------------------------------------------------------- $fhandle = fopen ("/scripts/thescript.sh" , "a"); $handle = fopen ("/scripts/mail_list.txt", "r"); while (!feof ($handle)) { $buffer = fgets($handle, 1000);Chances are, $buffer has the line break on it when you read it in from the text file. Try striping off whitespace before you write... while (!feof ($handle)) { $buffer = rtrim ( fgets($handle, 1000) ); fwrite ($fhandle, "chown $buffer:html http://www.php.net/manual/en/function.rtrim.php -- By-Tor.com It's all about the Rush http://www.by-tor.comfwrite ($fhandle, "chown $buffer:html /scripts/var/spool/mail/$buffer\n", 4096);} fclose ($handle); fclose ($fhandle);