473,385 Members | 1,472 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Newline doesn't work the second time...

The \n I write out to an open file does not work
the second time:

$xmlstr = "<?xml version=\"1.0\"\x3F>\n";
$songstr = "<songs>\n";

fwrite($handle, "$xmlstr"); //after this I got a new line
fwrite($handle, "$songstr"); //but not after this

$lines = file("./clips/$file_name");
foreach ($lines as $line_num => $line) {

fwrite($handle, " <song path=\"$line"); //$handle is another
file that I read data from
}

The output:

<?xml version="1.0"?>
<songs> <song path="http://209.245.59.124/song.mp3

Should be:

<?xml version="1.0"?>
<songs>
<song path="http://209.245.59.124/song.mp3
What do I do wrong??

Ralph
Jan 29 '06 #1
1 1111
Ralph Höglund wrote:
The \n I write out to an open file does not work
the second time:

$xmlstr = "<?xml version=\"1.0\"\x3F>\n";
$songstr = "<songs>\n";

fwrite($handle, "$xmlstr"); //after this I got a new line
fwrite($handle, "$songstr"); //but not after this

$lines = file("./clips/$file_name");
foreach ($lines as $line_num => $line) {

fwrite($handle, " <song path=\"$line"); //$handle is another file
that I read data from
}

The output:

<?xml version="1.0"?>
<songs> <song path="http://209.245.59.124/song.mp3

Should be:

<?xml version="1.0"?>
<songs>
<song path="http://209.245.59.124/song.mp3
What do I do wrong??

Ralph


what is your platform?
Feb 2 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: John Smith | last post by:
Hi all Why doesn't this seem to work? void stripnl(char *sz) { char *nl; nl = strchr(sz, '\n'); if (nl) {
29
by: runningdog | last post by:
Hi, I would like to be able to embed a newline in a text string. Is there any convienent notation to do this TIA Steve
0
by: Ralph Höglund | last post by:
The \n I write out to an open file does not work the second time: $xmlstr = "<?xml version=\"1.0\"\x3F>\n"; $songstr = "<songs>\n"; fwrite($handle, "$xmlstr"); //after this I got a new line...
4
by: Ralph Höglund | last post by:
The \n I write out to an open file does not work the second time: $xmlstr = "<?xml version=\"1.0\"\x3F>\n"; $songstr = "<songs>\n"; fwrite($handle, "$xmlstr"); //after this I got a new...
11
by: rossum | last post by:
I want to declare a const multi-line string inside a method, and I am having some problems using Environment.NewLine. I started out with: class foo { public void PrintStuff() { const...
11
by: Michael | last post by:
I'm new to PHP. I see that PHP supports the C printf function, and I've seen examples like printf("Hello world!\n"); however the newline character \n doesn't work - i.e., it does not generate an...
1
by: linq936 | last post by:
Hi, I read in many places that the string to be outputted by printf() must be ending with newline, for example, it should be printf("Hello World.\n"); instead of printf("Hello World.");
6
by: versus | last post by:
Hi I have a table column that has multiple lines (\r\n) and html tags in it. I want to display it in a div and label that html tags can be seen and newlines should work. If i use div.innerHTML...
4
by: Florian Lindner | last post by:
Hello, I have a piece of code like that: for row in resultSet: logs += "/home/%s/%s/log/access.log \n" % (row, row) logs += "/home/%s/%s/log/error.log \n" % (row, row) # <-- Now I want to...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.