I have an array of objects, each one just a string pair, like
$faq[0]->{"question"} = "Here is my question 1";
$faq[0]->{"answer"} = "Here is my answer 1";
$faq[1]->{"question"} = "Here is my question 2";
$faq[1]->{"answer"} = "Here is my answer 2";
and I want to convert it into XML like so:
<faq>
<question>Here is my question 1</question>
<answer>Here is my answer 1</answer>
</faq>
<faq>
<question>Here is my question 2</question>
<answer>Here is my answer 2</answer>
</faq>
I have no problem manually writing a function to do this, but it really feels like something that should be built into PHP, but I can't find it anywhere. Does some function exist, or should I just convert the data by writing my own function? Thanks!
Edit: A lot of people are suggesting a for loop and going through the array. That's kind of what I meant by "manually writing a function". I was just thinking that my situation is generic enough that PHP/SimpleXML may have a built-in function like
$xml->addContent($faq);
Which would do everything to parse the $faq variable and convert it to XML.