Php 筛选xml数据不起作用
我使用外部xml,这是可行的,但我有另一个问题。在我的_构造中,我有$elem,它负责过滤xml数据。但它不起作用。请帮忙。我不知道怎么咬它Php 筛选xml数据不起作用,php,xml,Php,Xml,我使用外部xml,这是可行的,但我有另一个问题。在我的_构造中,我有$elem,它负责过滤xml数据。但它不起作用。请帮忙。我不知道怎么咬它 class Property { public $xmlClass; public $array = []; public $elem = ''; public function __construct($xml,$elem) { $this->xmlClass=$xml; foreach($x
class Property {
public $xmlClass;
public $array = [];
public $elem = '';
public function __construct($xml,$elem) {
$this->xmlClass=$xml;
foreach($xml->list->film->$elem as $result) {
$array = array_push($result);
}
}
}
$result_scenario = new Property($xml,'scenario');
print_r($result_scenario);
array\u push
方法不是这样工作的
您需要将数组作为第一个参数传递,而不是传递要在其上推送的元素。在您的例子中,它将是array\u push($this->array,$result)代码>。函数返回数组中新的元素数
请参阅此处的文档,而不是说“它不工作”,您应该输入有关正在发生的事情的信息。例如,您是否收到错误消息?