下面这 2 行当前在 XML 文档中工作以产生 2 个值:
if (isset($images[0]->fname)) { $image1 = $theimgpath.'/'.$images[0]->fname; } else { $image1 = ''; }
if (isset($images[1]->fname)) { $image2 = $theimgpath.'/'.$images[1]->fname; } else { $image2 = ''; }
$image1 current value working = url within xml document require assignment to <image id="1">
$image2 current value = url working url within xml document require assignment to <image id="2">
$output .= "<url>".$image1."</url>\n"; example of current working value
上述工作在代码片段中的预期结果当前在以下相同的 xmldocument 中工作:
`$output .= "<property>\n";
$id = $xml["id"];
$id = $xml->image['id'];
$output .= $string = <<<XML
<images>
<image id="1"><url>id”1”</url></image>
<image id="2"><url>id”2”</url></image>
</images>
XML;
$output .= "</property>";
}
$output .= "</root>";`