我想将图像分配给PHP脚本中的变量,以便通过声明变量,可以在我想要的时候显示图像。
$FoodList = array_unique($FoodList);
if (!empty($FoodList)) {
foreach ($FoodList as $key => $value) {
// The variable would go here, so that image would appear
//next to each variable
echo "<li>" . $value . "<li>";
}
echo "</ul>";
}
答案 0 :(得分:1)
你指定 $ var =“img src =”'your / pathto / image.ext'“;
$var = "your/pathto/image.ext";
并在html img代码中回显它
第二种方法更为优选
答案 1 :(得分:1)
$FoodList = array_unique($FoodList);
if(!empty($FoodList)) {
foreach ($FoodList as $key => $value) {
//The variable would go here, so that image would appear
//next to each variable
$value = "<li>";
//Maybe you'll only display an image is a certain condition is met? If so, then...
if($condition == "parameter") {
$value .= "<img src='path/to/img' alt='img' />";
}
$value .= "</li>";
echo $value;
unset($value);
}
echo "</ul>";
}
答案 2 :(得分:0)
使用此:
echo "<li><img src='path_of_image/".$value."'/><li>";
假设$value
的图片名称为图片扩展名。
答案 3 :(得分:0)
$FoodList=array_unique($FoodList);
$img_path = 'images/example.jpg';
if(!empty($FoodList))
{
foreach ($FoodList as $key => $value)
{
echo "<img src='$img_path' />";
echo "<li>".$value."<li>";
}
echo "</ul>";
}
答案 4 :(得分:-1)
<?php
$name="Adil";
echo $name;
$path="FB_IMG_1465102989930.jpg";
for($i=0;$i<44;$i++)
{
echo($i.'<br>') ;
if($i==10)
{
echo ".$path.";
echo "<img src ='".$path."'>";
}
}
?>
答案 5 :(得分:-1)
请在图片名称前插入一个空格: - 示例: -
_collection.Aggregate()
.Match(...)
.Project(x => new { alias = x.IncludedField });
这里我在$image_name="myphoto.jpg";
$image_path="./upload/ ".$image_name;
将图像路径存储到MySql数据库中。
从您的HTML页面调用它: -
"./upload/(space)"