<?php
$fortressMapping = [
1 => <img src="<?php echo $image_url;?>">,'JG Fortress',
3 => <img src="<?php echo $image_url;?>">,'HT Fortress',
4 => <img src="<?php echo $image_url;?>">,'Ban Fortress',
6 => <img src="<?php echo $image_url;?>">,'Ban Fortress',
];如何在此代码中插入图像?
发布于 2017-05-29 01:50:24
您应该像这样使用它将元素添加到数组,现场演示
<?php
$fortressMapping = [
1 => "<img src=\"<?php echo $image_url;?>\">,'JG Fortress'",
.....
];发布于 2017-05-29 01:51:43
消除$fortressMapping内部的回波
<?php
$image_url = "http://example.com/image.png";
$fortressMapping = [
1 => '<img src="$image_url">','JG Fortress',
3 => '<img src="$image_url">','HT Fortress',
4 => '<img src="$image_url">','Ban Fortress',
6 => '<img src="$image_url">','Ban Fortress',
];
print_r($fortressMapping);发布于 2017-05-29 01:52:20
您不能在var赋值中回显:
$fortressMapping = [
1 => "<img src='{$image_url}'>",'JG Fortress',
3 => "<img src='{$image_url}'>",'HT Fortress',
4 => "<img src='{$image_url}'>",'Ban Fortress',
6 => "<img src='{$image_url}'>",'Ban Fortress',
];https://stackoverflow.com/questions/44233624
复制相似问题