如何将变量与连接它们的逗号分开并显示它们? [重复]

This question already has an answer here:

In a foreach loop I upload some photos and store their values into one variable seperated by a comma as below

$photos.=$file_name.",";

When the files are uploaded, in the DB it is saved as

01461135_1015205099943781_302247337_n.jpg,11534328_56640920111689_2120954548_n.jpg,2160948_470329406422631_1521154943_n.jpg,

please mind the , at the end.

My aim is to echo them later like below

        <li>
            <img src="images/car1.jpg" />
        </li>

My question is how can I separate the pictures knowing that the comma is at the end of the filename?

</div>

u can use the explode

explode (',',$UR-ARRAY,10);

for more example go to http://php.net/explode

I think you can explode your string and create an array of your pictures name

$picture_array = explode(",", $string);

Now all picture names are avaiable in $picture_array