Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从SimpleXMLElement获取变量_Php_Arrays_Xml_Variables_Simplexml - Fatal编程技术网

Php 从SimpleXMLElement获取变量

Php 从SimpleXMLElement获取变量,php,arrays,xml,variables,simplexml,Php,Arrays,Xml,Variables,Simplexml,如何从这个SimpleXMLElement中选择变量 如果我键入: var_dump($var); 我得到: object(SimpleXMLElement)#7423 (2) {["@attributes"]=>array(1) {["type"]=>string(3) "119"}[0]=>string(12) "10869715.jpg"} 我需要得到像“10869715.jpg”这样的结果 谢谢 如果我读对了你的转储,你不需要做什么特别的事情,因为你的物品是顶级物品

如何从这个SimpleXMLElement中选择变量

如果我键入:

var_dump($var);
我得到:

object(SimpleXMLElement)#7423 (2) {["@attributes"]=>array(1) {["type"]=>string(3) "119"}[0]=>string(12) "10869715.jpg"}
我需要得到像“10869715.jpg”这样的结果


谢谢

如果我读对了你的转储,你不需要做什么特别的事情,因为你的物品是顶级物品

<?php

$xml = "
<item type='119'>10869715.jpg</item>
";

$element = new SimpleXMLElement($xml);

echo ($element);

如果您能显示原始的XML,那么可以更容易地查看其结构。您好。请看一看,看看你能想出什么。如果你仍然被困在这里,请随意在这里发布一个特定的问题,并附上一个答案。
10869715.jpg