hi, I have varible call $output.This variable contains following values as it is.Order is same.
7.25474,80.59846 7.25478,80.59887 7.25246,80.59804 7.25126,80.59731 7.25126,80.59731
I want to write those values into a text file.But after wrote the values into text file the order of the values in text file should be as follows.(not in same line)
7.25474,80.59846
7.25478,80.59887
7.25246,80.59804
7.25126,80.59731
7.25126,80.59731
How can i do that...pls help me with this.
Thanks in advance..
pls help me to fix this simple thing...........
Moderator: General Moderators
Re: pls help me to fix this simple thing...........
Code: Select all
$lines = explode(' ', $output);
$fp = fopen($filename 'w+');
foreach ($lines as $line)
fwrite($fp, $line);
fclose($fp);Re: pls help me to fix this simple thing...........
try this:
$filename="decimalpairs.txt"
$fp=fopen($filename, "w");
$out_array = explode(" ", $output);
foreach ($out_array as $outpair)
{
fwrite($fp, "$outpair\n");
}
fclose($fp);
exit(0);
$filename="decimalpairs.txt"
$fp=fopen($filename, "w");
$out_array = explode(" ", $output);
foreach ($out_array as $outpair)
{
fwrite($fp, "$outpair\n");
}
fclose($fp);
exit(0);
Re: pls help me to fix this simple thing...........
Yeah, I missed the new line... but better use PHP_EOL instead of "\n"
Re: pls help me to fix this simple thing...........
Thanks I'm just learning PHP myself of didn't know what to use in lew of a UNIX newline '\n'
Re: pls help me to fix this simple thing...........
hey friends thanks lot.It worked well.I used PHP_EOL instead of /n.So thanks lot...............both of u guys.