Anthony Anthony - 3 months ago 10
PHP Question

php echo image with single and double quotes doesn't not work

How do I get this example echo image to work single and double?

data-mean="<?php
echo
'<div>' . $k["auto_ans"][$i] . '</div>' .
'<div><img src=' . $k["auto_image"][$i] . '></div>' .
'<div><img src=' . $k["auto_image2"][$i] . '></div>'; ?>"


I want it to output:

data-mean="<div>AAAA</div><div><img src='aaa.jpg'></div><div><img src='bbb.jpg></div>"

Answer

You should put quotes around SRC prop like this :

data-mean="<?php 
echo 
'<div>' . $k["auto_ans"][$i] . '</div>' .
'<div><img src=\'' . $k["auto_image"][$i] . '\'></div>' . 
'<div><img src=\'' . $k["auto_image2"][$i] . '\'></div>'; ?>"