PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
kholloi
Forum Newbie
Posts: 19 Joined: Tue Mar 30, 2004 1:08 am
Post
by kholloi » Fri Sep 10, 2004 1:56 am
Hi,
I am trying to format a string to write to a file. The entries mus be seperated by newlines.
I have been messing round with syntax for a while but can't seem to get it right.
Code: Select all
$string = $fileї0]."\n" BROADCAST=.$broadcast "\n" $fileї2] "\n" $fileї3] "\n" $fileї4] "\n" $fileї5] "\n" $fileї6] "\n" $fileї7] "\n" $fileї8] "\n";
What am I doing wrong please?
Thanks
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Sep 10, 2004 1:58 am
note how your string looks like with highlighting:
Code: Select all
$string = $file[0]."\n" BROADCAST=.$broadcast "\n" $file[2] "\n" $file[3] "\n" $file[4] "\n" $file[5] "\n" $file[6] "\n" $file[7] "\n" $file[8] "\n";
kholloi
Forum Newbie
Posts: 19 Joined: Tue Mar 30, 2004 1:08 am
Post
by kholloi » Fri Sep 10, 2004 2:08 am
OK. I supose that doesn't look right. Now i tried doing this:
Code: Select all
$string = '$fileї0]."\n" BROADCAST=.$broadcast "\n" $fileї2] "\n" $fileї3] "\n" $fileї4] "\n" $fileї5] "\n" $fileї6] "\n" $fileї7] "\n" $fileї8] "\n"';
but it interprets the whole string litterally? Doesn't read the "\n" tabs.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Sep 10, 2004 2:31 am
m3mn0n
PHP Evangelist
Posts: 3548 Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada
Post
by m3mn0n » Fri Sep 10, 2004 4:43 am
You got some serious syntax issues there.
I'd so as feyd recommends.
kholloi
Forum Newbie
Posts: 19 Joined: Tue Mar 30, 2004 1:08 am
Post
by kholloi » Fri Sep 10, 2004 8:01 am
OK I RTFM'ed.
Here is the solution if anyone is interested:
Code: Select all
$string = $fileї0]."\nBROADCAST="."'$broadcast'"."\nIPADDR="."'$fileї2]'"."\n".$fileї3]."\nNETMASK="."'$fileї4]'"."\n";
$string .= $fileї5]."\n".$fileї6]."\n".$fileї7]."\n".$fileї8]."\n";