I have a simple PHP code to save JSON to CSV , but I have an error, this the code:
<?php
$inputJSON = file_get_contents('https://url');
$out = fopen('C:\xampp\htdocs\tkp_product\tkp2.csv', 'w');
foreach(json_decode($inputJSON, true)["data"] as $key => $value) {
fputcsv($out, $value);
}
fclose($out);
?>
This for error for fputcsv($out, $value);
Notice: Array to string conversion in C:\xampp\htdocs\tkp.php on line 6
Notice: Array to string conversion in C:\xampp\htdocs\tkp.php on line 6
I'm running this script using XAMPP in Win 10 with PHP7 installed. What should I do to resolve this issue?