When I write $c8 to csv, it puts each iteration of $8 into a new column as designed, is there a way to write each iteration of $c8 to a new column instead of row? Or should should I use a different command. I can't seem to find one to accomplish this.
$field_names = array(
0 => "v_products_options_values_id", //Leave Blank, Maybe?
1 => "v_products_options_id", //Set to 1
2 => "v_products_options_values_name_1", //Needs to be split and filtered from options column
3 => "Action", //Leave Blank
);
$in = fopen("datafeed.csv" , "r");
$out = fopen("EPAvalues.csv", "w");
$src_field_names = array();
$in_stock = array();
$assoc_data_array = array();
$data_array = array();
//fputcsv($out , $field_names, ',');
while (($data = fgetcsv($in, 0, ",")) !== FALSE)
{
//Prevents printing of collumn headings
if(!$skphd)
{
$num = count($data);
for ($c=0, $i=0; $c < $num; $c++, $i++)
{
$src_field_names[$i] = $data[$c];
}
$skphd++;
$row = -1;
}
//Print Data from CSV File to screen
else
{
$num = count($data);
$row++;
for ($c=0, $i=0; $c < $num; $c++, $i++)
{
switch($src_field_names[$c])
{
case "COLOR-:-SIZE~QTY":
$pos = array_search("COLOR-:-SIZE~QTY", $src_field_names);
$data_array[$field_names[2].$row] = $data[$pos];
$c7 = explode(';',$data[7]); //Splits each COLOR-:-SIZE INTO ARRAY
$c8 = preg_replace('/(~....)|(~...)|(~..)|(~.)/',"", $c7); //REMOVES ALL ~???? DATA
fputcsv($out, $c8, ','); //Need $c8 to write to new row instead of new coloumn?????
break;
}
}
}
}
fclose($in);
fclose($out);