I’m trying to build a 3d php array, that ultimately gets outputted as xml… This is the code I’m trying to use to prove the concept…
$test = array('apple','orange');
$results = Array(
'success' => '1',
'error_number' => '',
'error_message' => '',
'results' => Array (
'number_of_reports' => mysql_num_rows($run),
'item' => $test
)
);
I want the resulting array to look like
<success>1</success>
<error_number/>
<error_message/>
<results>
<number_of_reports>18</number_of_reports>
<item>
<0>apple</0>
<1>orange</1>
</item>
</results>
In reality the apple and orange array would be a 3d one in itself… If you’ve ever used the ebay api… you’ll have an idea of what I’m trying to do (I think)
2
Answers
See below URL. I think it very use full to you:-
How to convert array to SimpleXML
Or Try it:-
Try it:
Code:
Output: