|
|
|
||||
|
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() |
|
|||||||
| Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
|
Thread Tools |
|
|
#1 |
|
Confirmed User
Industry Role:
Join Date: Jul 2001
Location: Utopia
Posts: 6,484
|
Att.: scriptfreaks - Removing empty lines from textfile w/php
Hi,
We have a script that is adding new lines for no apparent reason at this time. I want to get rid of the empty lines and re-order the text file every time somebody ads her/his name. The file is pretty simple, just lines, like this: line1 ... ... line2 ... line1001 ... I want to loose the ... lines and have it all nicely formatted, like this line1 line2 line1001 I use this script to add lines: PHP Code:
Thanks, Paul
__________________
seks.ai for sale - ping me |
|
|
|
|
|
#2 |
|
Confirmed User
Industry Role:
Join Date: Jul 2001
Location: Utopia
Posts: 6,484
|
Thanks :p
__________________
seks.ai for sale - ping me |
|
|
|
|
|
#3 |
|
Too lazy to set a custom title
Join Date: Mar 2002
Location: Australia
Posts: 17,393
|
Try putting the \n at the end rather than at the start.
fwrite($FilePointer, "$newitem\n"); or fputs($FilePointer, "$newitem\n"); |
|
|
|
|
|
#4 |
|
Confirmed User
Join Date: Apr 2003
Location: Loveland, CO
Posts: 5,526
|
just a guess, after you run your insert, rebuild the file?
$file = file_get_contents($FileName); $file = preg_replace("\n\n",$file); fwrite($FilePointer,$file); --- eh, nix that. probably an ugly way to do it. just get the file fixed and insert correct new lines like rowan said.
__________________
Your post count means nothing. |
|
|
|
|
|
#5 |
|
►SouthOfHeaven
Join Date: Jun 2004
Location: PlanetEarth MyBoardRank: GerbilMaster My-Penis-Size: extralarge MyWeapon: Computer
Posts: 28,609
|
put this as line #4
$newitem = trim($newitem); im new at this so i could be wrong
__________________
hatisblack at yahoo.com |
|
|
|
|
|
#6 |
|
Confirmed User
Industry Role:
Join Date: Jul 2001
Location: Utopia
Posts: 6,484
|
I did notice it just doubles the amoiunt of rows each time I update, add or edit a line from the file. I'm sure it has to do with /n, but I am still fucking around with it.
I'll try some of your options as well.
__________________
seks.ai for sale - ping me |
|
|
|
|
|
#7 |
|
Confirmed User
Industry Role:
Join Date: Jul 2001
Location: Utopia
Posts: 6,484
|
None of the above worked, any other takers?
__________________
seks.ai for sale - ping me |
|
|
|
|
|
#8 |
|
Confirmed User
Join Date: May 2004
Location: South Florida
Posts: 4,134
|
get rid of the \n when your appending to the file it already goes to the end of the file. The only time you need \n is if your appending multiple lines
|
|
|
|
|
|
#9 | |
|
Confirmed User
Industry Role:
Join Date: Jul 2001
Location: Utopia
Posts: 6,484
|
Quote:
If I do that, this line2 line3 ... becomes: line2line3 ... Using this code: PHP Code:
__________________
seks.ai for sale - ping me |
|
|
|
|
|
|
#10 |
|
Confirmed User
Industry Role:
Join Date: Jul 2001
Location: Utopia
Posts: 6,484
|
This works:
PHP Code:
__________________
seks.ai for sale - ping me |
|
|
|