我有这段代码
echo "<img src='" . $image[0] . "'>";
这个
<a href="/images/preview-kv/1.jpg" data-lightbox="roadtrip"><img src="images/preview-kv/1.jpg" alt=""></a>
我需要使用动态图像将其转换为php ... pls
答案 0 :(得分:0)
$image
是一个数组。
假设$image = array("/images/preview-kv/image1.png","/images/preview-kv/image2.png");
foreach($image as $image_path)
{
?>
<!--$image_value is dynamically changed-->
<a href="<?php echo $image_path; ?>" data-lightbox="roadtrip"><img src="<?php echo $image_path; ?>" alt=""></a>
<?php
}
答案 1 :(得分:0)
试试这些。我以src
中的variable
和$path = "/images/preview-kv/1.jpg";
$src = "images/preview-kv/1.jpg";
echo '<a href="'.$path.'" data-lightbox="roadtrip"><img src="'.$src.'" alt=""></a>';
为例
<a href="<?php echo $path ?>" data-lightbox="roadtrip"><img src="<?php echo $src ?>" alt=""></a>
或
{{1}}