Bala Murugan Bala Murugan - 1 month ago 10
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


.png


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

Some quotes and semicolon was missing. Try this:

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

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

$sizeOfa = sizeof($explodeA);

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