JM4 JM4 - 1 year ago 80
PHP Question

How to comma separate the values of an array for display

I have searched the site and originally thought of some use for the

function but doesn't seem to accomplish the goal:

I have an unknown number of values stored in a single array

$array1 = array(1,2,3,4,5);


$array1 = array(1,2,3);

I want to be able to echo (or
) the values contained within an array to screen and separated only by commas and spacing.

For example:

the 'idea' is to have echo
to display:


from the second example above.

Answer Source