Page 1 of 1

Inserting a blank line in file write

Posted: Mon Jan 23, 2006 2:36 pm
by vivsriaus
hawleyjr | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


Here is a piece of my code

Code: Select all

while ($data = fgetcsv ($fp, 1000)) {
	$num = count ($data);
	for ($c=0; $c < $num; $c++) {
		$mult[$row][$c] = $data[$c].",";
		//$mult[$row][$c] = $data[$c]
		fwrite($fp1, $mult[$row][$c]);
		}
	$row ++;
	}
I need to insert a blank line after each iteration of 'c' loop. ie., when the 1st iteration of the c loop exits, I need to insert a blank line and continue doin the same.

Any inputs?


hawleyjr | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Re: Inserting a blank line in file write

Posted: Mon Jan 23, 2006 2:58 pm
by Christopher
Something like:

Code: Select all

while ($data = fgetcsv ($fp, 1000)) {
	$num = count ($data);
	for ($c=0; $c < $num; $c++) {
		$mult[$row][$c] = $data[$c].",";
		//$mult[$row][$c] = $data[$c]
		fwrite($fp1, $mult[$row][$c]);
		}
	fwrite($fp1, "\n\n");
	$row ++;
	}

Posted: Wed Jan 25, 2006 11:40 am
by vivsriaus
yup!
I realize tht this is a stupid qstn which i posted in a hurry! I mustve lost my mind then! :))
Anyway, thnx

Posted: Wed Jan 25, 2006 12:10 pm
by nickman013
haha, welcome to the forums! :D

how i do it is, i just enter after the script

example

$content is being written to the page

Code: Select all

$content = "<html><title>My Site</title><font color=red size=3>This is my data!</font></html>
";
probably the wrong thing to do, what do i know :D

Posted: Wed Jan 25, 2006 12:30 pm
by Christopher
vivsriaus wrote:yup!
I realize tht this is a stupid qstn which i posted in a hurry! I mustve lost my mind then! :))
Anyway, thnx
Someone here said that there are no stupid questions -- only stupid answers. Well ... I agree about the questions. As for answers, as they are free, what is it about looking a gift horse in the mouth. :D

Posted: Wed Jan 25, 2006 5:06 pm
by John Cartwright
arborint wrote:
vivsriaus wrote:yup!
I realize tht this is a stupid qstn which i posted in a hurry! I mustve lost my mind then! :))
Anyway, thnx
Someone here said that there are no stupid questions -- only stupid answers. Well ... I agree about the questions. As for answers, as they are free, what is it about looking a gift horse in the mouth. :D
No stupid answers here.. unless its spam. :evil:

Posted: Wed Jan 25, 2006 5:08 pm
by d3ad1ysp0rk
nickman013 wrote:haha, welcome to the forums! :D

how i do it is, i just enter after the script

example

$content is being written to the page

Code: Select all

$content = "<html><title>My Site</title><font color=red size=3>This is my data!</font></html>
";
probably the wrong thing to do, what do i know :D
It works, but what happens when you want 3 line breaks? There goes the code readability ;)

Code: Select all

$content = "<html><title>My Site</title><font color=red size=3>This is my data!</font></html>\n\n\n";
That's the equivelant of 3 "enters".

Posted: Wed Jan 25, 2006 5:13 pm
by Christopher
d3ad1ysp0rk wrote:That's the equivelant of 3 "enters".
Yep. But would this be better:

Code: Select all

$content = "<html>\n<title>My Site</title>\n<font color=red size=3>This is my data!</font>\n</html>";

Posted: Wed Jan 25, 2006 9:35 pm
by nickman013
yeah, use the right way so nothing will get messed up

Posted: Thu Feb 02, 2006 10:18 pm
by d3ad1ysp0rk
arborint wrote:
d3ad1ysp0rk wrote:That's the equivelant of 3 "enters".
Yep. But would this be better:

Code: Select all

$content = "<html>\n<title>My Site</title>\n<font color=red size=3>This is my data!</font>\n</html>";
Of course it would be better, I was just introducing the use of \n, not a production-ready product. ;)