RE: [users@httpd] Delete Blank Lines In A Text File

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

 



That's nice but it doesn't fix the blank lines it just skips them in the
file parse.  I think he wants to clean the file.  If the file gets big,
he could take a performance hit skipping multiple lines.

 
Thanx
Aaron N Wagner
Monitoring Systems and Network Tools
CCO-Command Center Operations
804.515.6298
 

> -----Original Message-----
> From: Ken Robinson [mailto:kenrbnsn@xxxxxxxxx] 
> Sent: Tuesday, December 27, 2005 4:54 PM
> To: users@xxxxxxxxxxxxxxxx
> Subject: Re: [users@httpd] Delete Blank Lines In A Text File
> 
> Quoting Christopher Deeley <chrisdeeleyuk@xxxxxxxxx>:
> 
> > Does anyone know how to use PHP to delete blank lines in a 
> text file. I use
> > a text file to store usernames and passwords but with 
> adding and deleting
> > users, blank lines appear which returns an undefined offset 
> error when the
> > 'verify user script' tries to read each line of the text file.
> 
> Here's a short script:
>    <?php
>     $input = file('your_input_file.here'); // read file into 
> the array $input
>     $fp = fopen('your_output_file.here');
>     foreach ($input as $line)
>         if (trim($line) != '') fwrite($line);  // if the line 
> isn't blank write
> it out
>     fclose($fp);
>    ?>
> 
> 
> Ken
> 
> 
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP 
> Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
>    "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
> For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx
> 
> 

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux