我的数组存在问题。
我的输出显示为:
<article id="tab1">
<figure>
<img src="http://cdn.resize.flexmls.com/ric/640x480/true/20140820133948567093000000-o.jpg" >
<article id="tab2">
<figure>
<img src="http://cdn.resize.flexmls.com/ric/640x480/true/20140820133948862522000000-o.jpg" >
我无法关闭标签......
这是我的代码:
<?php
$photos = $rets->GetObject("Property", "640x480", $row["field_Value"], "*", 1);
foreach ($photos as $photo) {
$listing = $photo['Content-ID'];
$number = $photo['Object-ID'];
$location = $photo['Location'];
if ($photo['Success'] == true) {
// display on page
echo "<article id=\"tab$number\"> \n <figure>\n <img src=\"{$photo['Location']}\" > \n";
} else {
echo "({$listing}-{$number}): {$photo['ReplyCode']} = {$photo['ReplyText']}\n";
}
}
?>
<article id="tab<?=$number?>">
<figure>
<img src="<?=$location?>" alt="Photo" width="586" height="402" />
</figure>
答案 0 :(得分:1)
为什么你不能像在开始时那样在回声部分关闭它?
<?php
$photos = $rets->GetObject("Property", "640x480", $row["field_Value"], "*", 1);
foreach ($photos as $photo) {
$listing = $photo['Content-ID'];
$number = $photo['Object-ID'];
$location = $photo['Location'];
if ($photo['Success'] == true) { ?>
<article id="tab<?php echo $number; ?>">
<figure>
<img src="<?php echo "{$photo['Location']}"; ?>" >
</figure>
</article>
<?php
}
else
echo "({$listing}-{$number}): {$photo['ReplyCode']} = {$photo['ReplyText']}\n";
} ?>
答案 1 :(得分:0)
如果我完全理解你的意图,你只需要关闭那个初始if语句中的标签。所以代码看起来像这样
<?php
$photos = $rets->GetObject("Property", "640x480", $row["field_Value"], "*", 1);
foreach ($photos as $photo) {
$listing = $photo['Content-ID'];
$number = $photo['Object-ID'];
$location = $photo['Location'];
if ($photo['Success'] == true) {
// display on page
echo "<article id=\"tab$number\"> \n <figure>\n <img src=\"{$photo['Location']}\" > \n";
echo "</figure> \n";
echo "</article> \n";
} else {
echo "({$listing}-{$number}): {$photo['ReplyCode']} = {$photo['ReplyText']}\n";
}
?>