0
我從xml創建了一個緩存,並且通過構造我生成了最終成爲數組的對象。如果這些數組的鍵不是「0」,一切都會好的。我不知道它是如何工作的。我搜索瞭如何更改課程的信息,或者如何更換密鑰。我被卡住了。你能幫我解決這個問題嗎?爲什麼我的代碼在鍵和數組上生成:「0」
$xml = simplexml_load_file($cache);
}
class Property {
public $xmlClass;
public $elemClass = '';
public $result_array = [];
public $data = '';
public function __construct($xml,$elem) {
$this->xmlClass=$xml;
$this->elemClass=$elem;
foreach($xml->list->movie as $value) {
$data = $value->$elem;
$this->result_array[] = $data;
}
}
public function getResult() {
return $this->result_array;
}
}
$result_zn = new Property($xml,'zn');
$result_au = new Property($xml,'au');
$result_ti = new Property($xml, 'ti');
$zn = $result_zn->getResult();
$au = $result_au->getResult();
$ti = $result_ti->getResult();
這個問題不明確 –
一切正常,但此代碼(構造函數)生成的數據中,我有的鍵=「0」。這是我在嘗試捕獲這些數據並在之後使用它時的看法。不可能。 – Joey
不清楚你的意思。 – Havenard