如何在php中从数组中获得一行中的两个图像
请帮助我,我刚刚使用PHP从图库中提取图像。但现在我只想在一行中显示两个图像。在我指定的如何在php中从数组中获得一行中的两个图像,php,Php,请帮助我,我刚刚使用PHP从图库中提取图像。但现在我只想在一行中显示两个图像。在我指定的$content中返回它 请帮帮我 function CreateGalleryImages($types) { $galleryArray = array(); $galleryModel = new GalleryModel(); $galleryArray = ($galleryModel -> getGalleryByTypes($types)); $resul
$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>";
}
函数createGalleryImage($types){
$galleryArray=array();
$galleryModel=新galleryModel();
$galleryArray=($galleryModel->getGalleryByTypes($types));
$result=“”;
foreach($galleryArray作为$gallery){
对于($i=0;$i<2;$i++){
$result=“”
.""
."";
}
$result=“.$result.”;
}
返回“$result”;
}
您必须将结果连接起来并存储在$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>";
}
?>