Page 1 of 1

String format problems

Posted: Fri Sep 10, 2004 1:56 am
by kholloi
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

Posted: Fri Sep 10, 2004 1:58 am
by feyd
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";

Posted: Fri Sep 10, 2004 2:08 am
by kholloi
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.

Posted: Fri Sep 10, 2004 2:31 am
by feyd
read through the manual page about strings.. http://www.php.net/manual/en/language.types.string.php

Posted: Fri Sep 10, 2004 4:43 am
by m3mn0n
:shock:

You got some serious syntax issues there.

I'd so as feyd recommends.

Posted: Fri Sep 10, 2004 8:01 am
by kholloi
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";