Question

I had an XML that I turned into an array to sort it, now I want to save it as an XML again. This would not be a problem if I didn't have the following: [caseid] => Array ( [#text] => 885470 ...

I need: <caseid> 885470 </caseid>

Writing the DOM has been fine for the fieldname "caseid", but the fieldvalue is an array titled "#text" that I cannot figure out how to parse.

I can't search google for "#" symbols, so searching has been pretty tough.

Was it helpful?

Solution

I was able to access the number in the array by referencing it as a string. Stupid way to do it, but it works; the best solution would be to edit the array to xml conversion, but accessing array elements via strings worked too.

I was previously accessed array elements like so:

print_r($array[caseid][#text]); //<--Does not work with #
print_r($array[caseid]['#text']); //works 

Again, not the prettiest, but a viable workaround.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top