0

I've been searching stackoverflow all day looking for the right solution to this problem and I'm not sure if its just me not reading the solutions correctly or if I just simply don't understand it!

I have an Array which is produced directly from a source system that deals with my clients / invoices and sends the information out with attributes. Below is an example of the client array, but I'm looking for a solution that will then work on invoices and any other array structure I have and put it into a nested XML structure.

Array (
  [@attributes] => Array
  (
    [status] => ok
  )
  [clients] => Array
  (
    [@attributes] => Array
    (
      [page] => 1
      [per_page] => 25
      [pages] => 1
      [total] => 2
    )
  [client] => Array
    (
    [0] => Array
      (
      [client_id] => 77946
      [first_name] => Array
        (
        )
      [last_name] => Array
        (
        )
      [email] => test@test.com
      [username] => 5TKXFKNFka
      [home_phone] => Array
        (
        )
      [mobile] => Array
        ( 
        )
      [contacts] => Array 
        (
        ) 
      [organization] => Bob Billy
      [work_phone] => Array
        (
        )
      [fax] => Array
        (
        )
      [vat_name] => Array
        (
        )
      [vat_number] => Array
        (
        )
      [p_street1] => Array
        (
        )
      [p_street2] => Array
        (
        )
      [p_city] => Array 
        (
        )
      [p_state] => Array
        (
        )
      [p_country] => Array
        (
        )
      [p_code] => Array
        (
        )
      [s_street1] => Array
        (
        )
      [s_street2] => Array
        (
        )
      [s_city] => Array
        (
        )
      [s_state] => Array
        (
        )
      [s_country] => Array
        (
        )
      [s_code] => Array
        (
        )
      [notes] => Array
        (
        )
      [language] => en
      [currency_code] => GBP
      [folder] => active
      [updated] => 2016-02-11 07:47:13
      [credits] => Array
        (
          [credit] => 0
        )
      [credit] => 0
      [url] => 
      [auth_url] => 
      [links] => Array
        (
          [client_view] => 
          [view] => 
          [statement] => 
        )
      [notifications] => Array
        (
          [late_payment_reminders] => 1
        )
      )

    [1] => Array
    (
      [client_id] => 49607
      [first_name] => Bob
      [last_name] => Billy
      [email] => bob@bob.com
      [username] => bobbilly
      [home_phone] => 999
      [mobile] => 111
      [contacts] => Array
        (
        )
      [organization] => Bob Billy
      [work_phone] => Array
        (
        )
      [fax] => Array
        (
        )
      [vat_name] => VAT Number
      [vat_number] => Array
        (
        )
      [p_street1] => 123 Letsbe Avenue
      [p_street2] => Crimeville
      [p_city] => Prison
      [p_state] => Array
        (
        )
      [p_country] => United Kingdom
      [p_code] => NN101DW
      [s_street1] => Array
        (
        )
      [s_street2] => Array
        (
        )
      [s_city] => Array
        (
        )
      [s_state] => Array
        (
        )
      [s_country] => Array
        (
        )
      [s_code] => Array
        (
        )
      [notes] => Array
        (
        )
      [language] => en
      [currency_code] => GBP
      [folder] => active
      [updated] => 2016-02-11 10:49:29
      [credits] => Array
        (
        [credit] => 0
        )
      [credit] => 0
      [url] => 
      [auth_url] => 
      [links] => Array
        (
        [client_view] => 
        [view] => 
        [statement] => 
        )
      [notifications] => Array
        (
          [late_payment_reminders] => 1
        )
      )
    )
  )
) 

I know thats a lot of info above, but that is the total of 2 records. There will be quite a few records in the end, but I'd like to see the output as a standard XML format.

Anyone got any ideas? I just can't seem to fa therm it.

Thanks in advance.

Richard C
  • 401
  • 1
  • 5
  • 19
  • @miken32 - I did try that solution already, but it just produced the following: `status<1>page<25>per_page<1>pages<2>total<77946>client_idemail<5TKXFKNFka>usernameorganizationlanguagecurrency_codefolder<47:13>updated<0>credit<0>crediturlauth_urlclient_viewviewstatement<1>late_payment_reminders<49607>client_idfirst_namelast_nameemailusername<999>home_phone<111>mobileorganizationvat_name<123 Letsbe Avenue>p_street1p_street2p_cityp_countryp_codelanguagecurrency_codefolder<49:29>updated<0>credit<0>crediturlauth_urlclient_viewviewstatement<1>late_payment_reminders` – Richard C Feb 11 '16 at 18:30
  • Third answer looks to be the one you want. – miken32 Feb 11 '16 at 18:33

0 Answers0