We are trying export CSV in below format: enter image description here
We are receiving JSON from front-end in below format:
{"items":[{"itemTitle":"Item1","categoryName":"1","itemQuantity":"10","itemdescription":"Item1 Discription"}],"name":"Ram Bariya","email":"arbariya@gmail.com","phone":"8980624186","company":"Ultimate-ss","requestpickup":"Yes"}
PHP sample code logic which we are trying, other items row everything working fine.
$col=json_decode($_POST['dataToJson']);
$items=$col->items;
$fullname=$col->name;
$email=$col->email;
$phone=$col->phone;
$company=$col->company;
$requestpickup=$col->requestpickup;
$file_open = fopen("eauction_data.csv", "w+");
fputcsv($file_open, explode(",", $fullname));
fputcsv($file_open, explode(",", $email));
fputcsv($file_open, explode(",", $phone));
fputcsv($file_open, explode(",", $company));
fputcsv($file_open, explode(",", $requestpickup));
foreach ($items as $line) {
fputcsv($file_open,explode(',',$line));
}
fclose($file_open);
Below is sample output for above code snippet: enter image description here