Ich weiß nicht, wie Sie dieses JSON-Array in eine CSV konvertieren.JSON Array in CSV mit Zeilennamen konvertieren?
[relatedProducts] => Array
(
[0] => 111001
[1] => 111002
[2] => 111007
[3] => 111021
[4] => 111022
[5] => 111024
[6] => 111027
[7] => 111121
[8] => 111122
[9] => 111127
[10] => 111128
[11] => 111141
[12] => 111142
[13] => 111144
[14] => 111147
)
Ich mag relatedProducts
der Zeile Name sein und im Bereich unterhalb von relatedProducts
sollte es sein „111001,111002,111007 .....“
relatedProducts
111001,111002,111007
Was ich versucht habe, ist etwas, dies wie:
foreach($array as $obj)
{
$related = $obj->relatedProducts;
};
if (empty($firstLineKeys))
{
$firstLineKeys = array_keys($relatedProducts);
fputcsv($f, $firstLineKeys, ';');
$firstLineKeys = array_flip($firstLineKeys);
}
fputcsv($f, $relatedProducts, ';');
Was mit falsch dein Code? Erhalten Sie einen Fehler? –