title: Convert array into csv
body: <p>How to convert an array into a CSV file?</p>
  
  <p>This is my array:</p>
  
  <pre><code>stdClass Object
  (
  
      [OrderList_RetrieveByContactResult] =&gt; stdClass Object
          (
              [OrderDetails] =&gt; stdClass Object
                  (
                      [entityId] =&gt; 1025298
                      [orderId] =&gt; 10952
                      [orderName] =&gt; testing
                      [statusTypeId] =&gt; 4652
                      [countryCode] =&gt; AU
                      [orderType] =&gt; 1
                      [invoiceNumber] =&gt; 0
                      [invoiceDate] =&gt; 0001-01-01T00:00:00
                      [userID_AssignedTo] =&gt; 11711
                      [shippingAmount] =&gt; 8.95
                      [shippingTaxRate] =&gt; 0
                      [shippingAttention] =&gt; 
                      [shippingInstructions] =&gt; 
                      [shippingOptionId] =&gt; 50161
                      [discountCodeId] =&gt; 0
                      [discountRate] =&gt; 0
                      [totalOrderAmount] =&gt; 408.45
                      [directDebitTypeId] =&gt; 0
                      [directDebitDays] =&gt; 0
                      [isRecur] =&gt; 
                      [nextInvoiceDate] =&gt; 0001-01-01T00:00:00
                      [endRecurDate] =&gt; 0001-01-01T00:00:00
                      [cycleTypeID] =&gt; 1
                      [createDate] =&gt; 2010-10-08T18:40:00
                      [lastUpdateDate] =&gt; 2010-10-08T18:40:00
                      [deleted] =&gt; 
                      [products] =&gt; stdClass Object
                          (
                              [Product] =&gt; stdClass Object
                                  (
                                      [productId] =&gt; 674975
                                      [productCode] =&gt; 
                                      [productDescription] =&gt; 
                                      [units] =&gt; 10
                                      [unitPrice] =&gt; 39.95
                                      [unitTaxRate] =&gt; 0
                                      [totalProductPrice] =&gt; 399.5
                                      [productName] =&gt; Acne Clearing Gel
                                  )
  
                          )
  
                      [addresses] =&gt; stdClass Object
                          (
                              [Address] =&gt; stdClass Object
                                  (
                                      [addressTypeID] =&gt; 8
                                      [addressLine1] =&gt; Cebu City
                                      [city] =&gt; Cebu
                                      [zipcode] =&gt; 6000
                                      [state] =&gt; 
                                      [countryCode] =&gt; PH
                                  )
  
                          )
  
                  )
  
          )
  
  )
  </code></pre>