如何访问数组元素“Array ( [#text] ==>”
我有一个 XML,我将其转换为数组以对其进行排序,现在我想再次将其另存为 XML。如果我没有以下内容,这不会成为问题: [caseid] => Array ( [#text] => 885470 ...
我需要:
编写 DOM 对于字段名“caseid”来说很好,但 fieldvalue 是一个标题为“#text”的数组,我无法弄清楚如何解析它,
我无法在谷歌中搜索“#”符号,因此搜索非常困难。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我能够通过将数组中的数字作为字符串引用来访问它。虽然方法很愚蠢,但确实有效;最好的解决方案是编辑数组到 xml 的转换,但通过字符串访问数组元素也可以。
我以前是这样访问数组元素的:
同样,这不是最漂亮的,而是一个可行的解决方法。
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:
Again, not the prettiest, but a viable workaround.