Làm cách nào để chuyển đổi mảng thành tệp CSV?Chuyển đổi mảng thành csv
Đây là mảng của tôi:
stdClass Object
(
[OrderList_RetrieveByContactResult] => stdClass Object
(
[OrderDetails] => stdClass Object
(
[entityId] => 1025298
[orderId] => 10952
[orderName] => testing
[statusTypeId] => 4652
[countryCode] => AU
[orderType] => 1
[invoiceNumber] => 0
[invoiceDate] => 0001-01-01T00:00:00
[userID_AssignedTo] => 11711
[shippingAmount] => 8.95
[shippingTaxRate] => 0
[shippingAttention] =>
[shippingInstructions] =>
[shippingOptionId] => 50161
[discountCodeId] => 0
[discountRate] => 0
[totalOrderAmount] => 408.45
[directDebitTypeId] => 0
[directDebitDays] => 0
[isRecur] =>
[nextInvoiceDate] => 0001-01-01T00:00:00
[endRecurDate] => 0001-01-01T00:00:00
[cycleTypeID] => 1
[createDate] => 2010-10-08T18:40:00
[lastUpdateDate] => 2010-10-08T18:40:00
[deleted] =>
[products] => stdClass Object
(
[Product] => stdClass Object
(
[productId] => 674975
[productCode] =>
[productDescription] =>
[units] => 10
[unitPrice] => 39.95
[unitTaxRate] => 0
[totalProductPrice] => 399.5
[productName] => Acne Clearing Gel
)
)
[addresses] => stdClass Object
(
[Address] => stdClass Object
(
[addressTypeID] => 8
[addressLine1] => Cebu City
[city] => Cebu
[zipcode] => 6000
[state] =>
[countryCode] => PH
)
)
)
)
)
Bạn có thể muốn gắn thẻ câu hỏi này với bất cứ ngôn ngữ mã của bạn được viết bằng đó sẽ giúp bạn có được cách dõi theo những câu hỏi của bạn. :) –
tôi không nghĩ rằng có một cách để trình bày đa chiều trong CSV, là có? – Hannes
Xem thêm [giải pháp này] (http://stackoverflow.com/a/13474770/57091) sử dụng 'fputcsv()' kết hợp với 'ob_start(); $ df = fopen ("php: // output", 'w'); fclose ($ df); return ob_get_clean(); '. – robsch