Jump to content

[SOLVED] Inserting dynamic values when outputting to a file?


scott.stephan

Recommended Posts

I'm getting closer! Right now, I want to export a small amount of data to a .csv: a purchase order number followed by "1", i.e. "61751,1" and I need for the file to have a unique name, preferrably something like ponum_export, i.e. 61751_export.

 

So, I managed to get the file to write and name if I provided static data. The problem arises because I have my po_num stored in a variable. Here's the code I have now:

 

//Output to a .csv: "po_num,1" to trip the validate flag in SAGE
	$list = array (
	'$curr_po_num,1'
	);

	//Give it a unique name to avoid possible conflicts if Batch is delayed
	$fp = fopen('$curr_po_num_validation.csv', 'w');

	foreach ($list as $line) {
		fputcsv($fp, split(',', $line));
	}

	fclose($fp);

 

The problem is that I get a file named "$curr_po_num_validation.csv" and the file contains "$curr_po_num,1". Meaning that instead of the value of $curr_po_num, I get "$_curr_po_num"  :D

 

There must be a simple answer that I am too goofy to see. Thoughts?

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.