Jump to content

PHP fputcsv line breaking wrong.


scott.stephan

Recommended Posts

This is probably a dumb question, but I've been up for almost 48 hours and I just wanna smash this problem to pieces! Anyway- I'm Fputcsv 'ing and I want everything on ONE LINE. Instead, I'm getting 4 seperate lines:

 

$list = array (
	"$curr_po_num","1","$curr_carrier","$curr_pro"
	);
	$filename=$curr_po_num."_validation.csv";

	$fp = fopen($filename, 'w');
	foreach ($list as $line) {
		fputcsv($fp, split(',', $line));
	}
	fclose($fp);

 

I want: ponum,1,carrier,pro

I'm getting:

ponum

1

carrier

pro

 

Probably a really goofy error, I'm just running circles around myself.

Link to comment
https://forums.phpfreaks.com/topic/162204-php-fputcsv-line-breaking-wrong/
Share on other sites

Try this:

 

$list = array (
"$curr_po_num","1","$curr_carrier","$curr_pro"
      );
      $filename=$curr_po_num."_validation.csv";
      
      $fp = fopen($filename, 'w');
       fputcsv($fp,$list);
      fclose($fp);

 

Also, read the docs for fputcsv.

 

HTH,

M.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.