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
vivsriaus
Forum Newbie
Posts: 7 Joined: Tue Jan 10, 2006 11:03 am
Post
by vivsriaus » Mon Jan 23, 2006 2:36 pm
hawleyjr | Please use 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 codeCode: 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
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Christopher
Site Administrator
Posts: 13596 Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US
Post
by Christopher » Mon Jan 23, 2006 2:58 pm
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 ++;
}
(#10850)
vivsriaus
Forum Newbie
Posts: 7 Joined: Tue Jan 10, 2006 11:03 am
Post
by vivsriaus » Wed Jan 25, 2006 11:40 am
yup!
I realize tht this is a stupid qstn which i posted in a hurry! I mustve lost my mind then!
)
Anyway, thnx
nickman013
Forum Regular
Posts: 764 Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York
Post
by nickman013 » Wed Jan 25, 2006 12:10 pm
haha, welcome to the forums!
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
Christopher
Site Administrator
Posts: 13596 Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US
Post
by Christopher » Wed Jan 25, 2006 12:30 pm
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.
(#10850)
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Wed Jan 25, 2006 5:06 pm
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.
No stupid answers here.. unless its spam.
d3ad1ysp0rk
Forum Donator
Posts: 1661 Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA
Post
by d3ad1ysp0rk » Wed Jan 25, 2006 5:08 pm
nickman013 wrote: haha, welcome to the forums!
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
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".
Christopher
Site Administrator
Posts: 13596 Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US
Post
by Christopher » Wed Jan 25, 2006 5:13 pm
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>";
(#10850)
nickman013
Forum Regular
Posts: 764 Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York
Post
by nickman013 » Wed Jan 25, 2006 9:35 pm
yeah, use the right way so nothing will get messed up
d3ad1ysp0rk
Forum Donator
Posts: 1661 Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA
Post
by d3ad1ysp0rk » Thu Feb 02, 2006 10:18 pm
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.