【发布时间】:2013-02-07 05:09:57
【问题描述】:
我正在尝试从查询结果中检索数据。现在我正在尝试的是,如果问题没有图像,则只输出空白,否则如果问题确实有图像,则使用图像标签输出图像。唯一的问题是它一直在输出Array。
我哪里错了?
<?php foreach ($arrQuestionId as $key => $question) { ?>
<div class='lt-container'>
<p><?php echo htmlspecialchars($arrQuestionNo[$key]) . ": " . htmlspecialchars($arrQuestionContent[$key]); ?></p>
<?php
//start:procedure image
$img_result = '';
if (empty($arrImageFile[$key])) {
$img_result = ' ';
} else {
?>
<p>
<img alt="<?php echo $arrImageFile[$key]; ?>" height="200" width="200" src="<?php echo $arrImageFile[$key]; ?>">
</p>
<?php
}
//end:procedure image
?>
</div>
<?php } ?>
【问题讨论】:
-
$arrImageFile[$key] 是一个数组吗? $arrImageFile[$key][0] 给你第一张图片?
-
显示你得到的数组...
-
print_r($arrImageFile) 将为您提供该数组的结构并根据该结构回显。
-
var_dump($arrImageFile)检查它是否符合您的预期。 -
你能发布 $arrQuestionId 结构吗?