gorilla1
03-11-2005, 03:19 AM
I'm having trouble with handling "/n" in a file, as follows...
I have a file I have created by this code, which contains the file names of some images:
$entry_line = ($value ) . "\n";
fwrite( $fp, $entry_line);
I then create an array by reading this file:
$data = file($filename);
And I want to write a new file the contains both the file names and extensions, 1.jpg, 2.jpg, etc., separated by "|".
So, I want to use:
$lineout = "|" . $lineout . ".jpg";
fputs($fp,$lineout);
However, the line break ("/n") gets in the way, and the files ends up like this:
|1
.jpg|2
.jpg|3
.jpg
If I try:
str_replace("/n", ".jpg\n", $lineout);
the "/n" is never seen, so the replace never occurs.
How can I output the records so they look like:
|1.jpg
|2.jpg
etc? (of course, the values, 1, 2, 3 etc. will vary, so I cannot just str_replace on them)
G
I have a file I have created by this code, which contains the file names of some images:
$entry_line = ($value ) . "\n";
fwrite( $fp, $entry_line);
I then create an array by reading this file:
$data = file($filename);
And I want to write a new file the contains both the file names and extensions, 1.jpg, 2.jpg, etc., separated by "|".
So, I want to use:
$lineout = "|" . $lineout . ".jpg";
fputs($fp,$lineout);
However, the line break ("/n") gets in the way, and the files ends up like this:
|1
.jpg|2
.jpg|3
.jpg
If I try:
str_replace("/n", ".jpg\n", $lineout);
the "/n" is never seen, so the replace never occurs.
How can I output the records so they look like:
|1.jpg
|2.jpg
etc? (of course, the values, 1, 2, 3 etc. will vary, so I cannot just str_replace on them)
G