所以我有这个代码:
foreach ($xml->PrintQuestion as $PrintQuestion) {
//if hint doesn't exist, store question id
if (!$PrintQuestion->content->multichoice->feedback->hint->Passage) {
fwrite($fp, "<contentid filename=\"$value\">" . $PrintQuestion->attributes()->id . "</contentid>");
}
}
Run Code Online (Sandbox Code Playgroud)
基本上,如果Passage节点存在,我正在尝试将ID保存到XML文件,但它似乎存储每个ID,无论节点是否存在Passage.
如果你使用会发生什么 empty()
if( empty($PrintQuestion->content->multichoice->feedback->hint->Passage) ) {
fwrite($fp, "<contentid filename=\"$value\">" . $PrintQuestion->attributes()->id . "</contentid>");
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3666 次 |
| 最近记录: |