Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: XML z tablicy
Forum PHP.pl > Forum > PHP
busterek
Mam pewien problem.
Mam następującą tablicę:

  1. (
  2. [orders] => Array
  3. (
  4. [0] => Array
  5. (
  6. [order] => Array
  7. (
  8. [orderId] => 23570
  9. [cstShippingFirstName] => imie
  10. [cstShippingLastName] => nazwisko
  11. [cstShippingCompany] =>
  12. [cstShippingStreet] => ulica
  13. [cstShippingStreetNumber] => 00
  14. [cstShippingPostCode] => 00-000
  15. [cstShippingCity] => Miasto
  16. [cstShippingCountry] => Kraj
  17. [cstPaymentFirstName] => ulica
  18. [cstPaymentLastName] => nazwisko
  19. [cstPaymentCompany] =>
  20. [cstPaymentStreet] => ulica
  21. [cstPaymentStreetNumber] => 00
  22. [cstPaymentPostCode] => 00-000
  23. [cstPaymentCity] => Miasto
  24. [cstPaymentCountry] => Kraj
  25. [products] => Array
  26. (
  27. [product] => Array
  28. (
  29. [0] => Array
  30. (
  31. [ean] => 1234567938875
  32. [price] => 14.2276
  33. [qty] => 2
  34. )
  35.  
  36. [1] => Array
  37. (
  38. [ean] => 1234567938875
  39. [price] => 14.2276
  40. [qty] => 2
  41. )
  42.  
  43. [2] => Array
  44. (
  45. [ean] => 1234567938875
  46. [price] => 14.2276
  47. [qty] => 2
  48. )
  49.  
  50. [3] => Array
  51. (
  52. [ean] => 1234567936420
  53. [price] => 14.6341
  54. [qty] => 1
  55. )
  56.  
  57. [4] => Array
  58. (
  59. [ean] => 1234567936420
  60. [price] => 14.6341
  61. [qty] => 1
  62. )
  63.  
  64. [5] => Array
  65. (
  66. [ean] => 1234567936420
  67. [price] => 14.6341
  68. [qty] => 1
  69. )
  70.  
  71. [6] => Array
  72. (
  73. [ean] => 1234567936420
  74. [price] => 14.6341
  75. [qty] => 1
  76. )
  77. )
  78. )
  79. )
  80. )
  81. [1] => Array
  82. (
  83. [order] => Array
  84. (
  85. [orderId] => 23571
  86. [cstShippingFirstName] => imie
  87. [cstShippingLastName] => nazwisko
  88. [cstShippingCompany] =>
  89. [cstShippingStreet] => ulica
  90. [cstShippingStreetNumber] =>
  91. [cstShippingPostCode] => 00-000
  92. [cstShippingCity] => Miasto
  93. [cstShippingCountry] => Kraj
  94. [cstPaymentFirstName] => imie
  95. [cstPaymentLastName] => nazwisko
  96. [cstPaymentCompany] =>
  97. [cstPaymentStreet] => ulica
  98. [cstPaymentStreetNumber] =>
  99. [cstPaymentPostCode] => 00-000
  100. [cstPaymentCity] => Miasto
  101. [cstPaymentCountry] => Kraj
  102. [products] => Array
  103. (
  104. [product] => Array
  105. (
  106. [0] => Array
  107. (
  108. [ean] => 1234567934952
  109. [price] => 219.5122
  110. [qty] => 1
  111. )
  112.  
  113. [1] => Array
  114. (
  115. [ean] => 1234567935294
  116. [price] => 8.1301
  117. [qty] => 1
  118. )
  119.  
  120. [2] => Array
  121. (
  122. [ean] => 1234567935379
  123. [price] => 13.8211
  124. [qty] => 1
  125. )
  126.  
  127. [3] => Array
  128. (
  129. [ean] => 1234567935270
  130. [price] => 17.0732
  131. [qty] => 1
  132. )
  133.  
  134. [4] => Array
  135. (
  136. [ean] => 1234567935447
  137. [price] => 20.3252
  138. [qty] => 1
  139. )
  140.  
  141. [5] => Array
  142. (
  143. [ean] => 1234567935263
  144. [price] => 27.6423
  145. [qty] => 1
  146. )
  147.  
  148. [6] => Array
  149. (
  150. [ean] => 1234567935393
  151. [price] => 38.2114
  152. [qty] => 1
  153. )
  154.  
  155. [7] => Array
  156. (
  157. [ean] => 1234567935256
  158. [price] => 42.2764
  159. [qty] => 1
  160. )
  161. )
  162. )
  163. )
  164. )
  165. )
  166. )


I teraz chciałbym przekonwertować ją do xml-a o strukturze:

  1. <orders>
  2. <order>
  3. ...
  4. <products>
  5. <product>
  6. ...
  7. </product>
  8. </products>
  9. </order>
  10. <order>
  11. ...
  12. </order>
  13. </orders>


Wiadomo. Zamówień może być x. Znalazłem jedno rozwiązaanie, ale ono tworzy mi strukturę:

  1. <orders>
  2. <order>
  3. ...
  4. <products>
  5. <product>
  6. ...
  7. </product>
  8. </products>
  9. </order>
  10. </orders>
  11. <orders>
  12. <order>
  13. ...
  14. </order>
  15. </orders>


Może ja mam źle skonstruowaną tablicę? Podpowiedzcie coś.

nospor
Cytat
Może ja mam źle skonstruowaną tablicę?

Ze wszystkich mozliwosci naprawde musiales wybrac te? wink.gif
A moze poprostu masz zly skrypt ktory generuje ci XML i tyle. A moze nie tyle zly, co dzialajacy inaczej niz ty by oczekiwal. Wiec go popraw. A jak nie potrafisz, to w klej tutaj jego kod
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.