Merge array items into string

Use the implode function.

For example:

$fruits = array('apples', 'pears', 'bananas');
echo implode(',', $fruits);

Try this from the PHP manual (implode):

<?php
    $array = array('lastname', 'email', 'phone');
    $comma_separated = implode(",", $array);

    echo $comma_separated; // lastname, email, and phone

    // Empty string when using an empty array:
    var_dump(implode('hello', array())); // string(0) ""
?>

If you are trying to just concatenate all of strings in the array, then you should look at implode().


$array1 = array(
    "one",
    "two",
)
$array2 = array(
    "three",
    "four",
)
$finalarr = array_merge($array1, $array2);
$finalarr = implode(",", $finalarr);

will produce this one,two,three,four