0
在PHP腳本中,我想編輯一個節點及其屬性。PHP-SimpleXML:編輯節點及其屬性
<config>
<Week>
<Monday from="18:00:00" to="8:00:00">true</Monday>
<Tuesday from="18:00:00" to="8:00:00">true</Tuesday>
</Week></config>
foreach ($config->Week->children() as $day){
$day = $_POST["b_".$day];
$day['from'] = $_POST[$day."_from"];
$day['to'] = $_POST[$day."_to"];
}
這似乎並沒有工作。但這並
$config->Week->Monday = $_POST['b_Monday'];
$config->Week->Monday['from'] = $_POST['Monday_from'];
$config->Week->Monday['to'] = $_POST['Monday_to'];
有沒有辦法做到這一點在一個循環中,所以我在沒有硬編碼的節點名稱?從日
推薦閱讀:[如何在PHP中獲取有用的錯誤消息?](http://stackoverflow.com/q/845021/367456) – hakre