<?php
$myarray = array(
array(
['sku'] =>'asdfa'
)
array(
array(['sku'] =>'asdfa'
)
);
like this array
$productArray = array();
$productArray[0]['code'] = "Code";
$productArray[0]['name'] = "name";
$productArray[0]['product_group_description'] = "Product Group Description";
$productArray[0]['actual_quantity'] = "Actual Quantity";
$productArray[0]['cost'] = "Cost";
$i = 1;
foreach($myArray as $products){
$productArray[$i]['code'] = $products['sku'];
$productArray[$i]['name'] = "";
$productArray[$i]['product_group_description'] = "";
$productArray[$i]['actual_quantity'] = $products['qty'];
$productArray[$i]['cost'] = $products['price'];
$i++;
}
/* echo '<pre>';
print_r($productArray);
exit; */
$remote_file_name = 'productbody/Powerbody.csv';
$fp = fopen($remote_file_name, 'w');
foreach ($productArray as $row) {
fputcsv($fp, $row);
}
//rewind($fp);
//ftp_fput($ftp_conn, $remote_file_name, $fp, FTP_ASCII);
fclose($fp);
?>
$myarray = array(
array(
['sku'] =>'asdfa'
)
array(
array(['sku'] =>'asdfa'
)
);
like this array
$productArray = array();
$productArray[0]['code'] = "Code";
$productArray[0]['name'] = "name";
$productArray[0]['product_group_description'] = "Product Group Description";
$productArray[0]['actual_quantity'] = "Actual Quantity";
$productArray[0]['cost'] = "Cost";
$i = 1;
foreach($myArray as $products){
$productArray[$i]['code'] = $products['sku'];
$productArray[$i]['name'] = "";
$productArray[$i]['product_group_description'] = "";
$productArray[$i]['actual_quantity'] = $products['qty'];
$productArray[$i]['cost'] = $products['price'];
$i++;
}
/* echo '<pre>';
print_r($productArray);
exit; */
$remote_file_name = 'productbody/Powerbody.csv';
$fp = fopen($remote_file_name, 'w');
foreach ($productArray as $row) {
fputcsv($fp, $row);
}
//rewind($fp);
//ftp_fput($ftp_conn, $remote_file_name, $fp, FTP_ASCII);
fclose($fp);
?>
Comments
Post a Comment