Reply to Too many line breaks !?

Your name:

Reply:


Posted by Pete on 01/07/06 22:11

I am having a file with this content:
a,2
b,1
c,3
d,4

I read it from a php script, import it into arrays and recreate the file
content from the arrays and write it into the file again. The file now looks
like this:
a,2

b,1

c,3

d,4


Where do the extra line breaks come from!? The script looks like this:

<?
$filename = "test.txt";

// Read file and import into arrays
$file_lines = file($filename);
for($i=0; $i<count($file_lines); $i++) {
$split = explode(",", $file_lines[$i]);
$arr1[$i] = $split[0];
$arr2[$i] = $split[1];
}

// Create file content from arrays and write to file
for($i=0; $i<count($arr1); $i++) {
$file_txt .= $arr1[$i].",".$arr2[$i]."\n";
}
$tofile = fopen($filename, "w"); fputs($tofile, $file_txt); fclose($tofile);

?>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация