Bala Murugan Bala Murugan - 9 months ago 50
PHP Question

Split Value Into Array separated List and display the Value as a "IMAGE"

I Have a Variable

$a = 1,2,3,4;

split value into array separated by ',' using Explode

$explodeA = explode(",", $a)
$sizeOfa = sizeof($explodeA);

Finally concatenate


into array listed values.

for($i = 0; $i < $sizeOfa; $i++)
<img src="<?php echo $explodeA[$i]."."."png";?>">

But the images are not displayed, WHY?. I Have The Following Images

1.png, 2.png, 3.png, 4.png .

Answer Source

Some quotes and semicolon was missing. Try this:

$a ="1,2,3,4";

$explodeA = explode(",",$a);

$sizeOfa = sizeof($explodeA);

    echo '<img src="'.$explodeA[$i].'.png">';