请帮助我,我刚刚使用PHP从图库中提取图像。但现在我只想在一行中显示两张图像。返回我指定的$content
请帮帮我。
function CreateGalleryImages($types) {
$galleryArray = array();
$galleryModel = new GalleryModel();
$galleryArray = ($galleryModel -> getGalleryByTypes($types));
$result = "";
foreach ($galleryArray as $gallery) {
for ($i = 0; $i < 2; $i++){
$result = "<td>"
."<img runat = 'server' src = 'http://localhost/schoolwb/event/$gallery' height=500 width=500 />"
."</td>";
}
$result = "<tr>.$result.</tr>";
}
return "<table class = 'GalleryTable'> . $result . </table>";
}
您必须将结果concatenate
并存储在$result
中。
试试这个
<?php
function CreateGalleryImages($types){
$galleryArray = array();
$galleryModel = new GalleryModel();
$galleryArray = ($galleryModel->getGalleryByTypes($types));
$result = "";
foreach ($galleryArray as $gallery){
$cl = "";
for ($i = 0;$i<2;$i++){
$cl .= "<td>"
."<img runat = 'server' src = 'http://localhost/schoolwb/event/$gallery' height=500 width=500 />"
."</td>";
}
$result .= "<tr>.$cl.</tr>";
}
return "<table class = 'GalleryTable'>.$result.</table>";
}
?>