Joining all array elements up to form one string in PHP
To transfer all elements of an array into one string the function implode() is required. Simple specify the array that is to be imploded along with a separator.
In our example we shall use an array containing fruits, and transform the array $fruits into a simple comma separated string. Here is how it is done:
$fruits = array(
$fruits = implode($fruits, ', ');
echo "Fruits: ".$fruits;
That is all that there is to it. The function implode can certainly save some time when compared to joining an array up into a string via a loop, although a loop could offer more control for advanced distinguishing between the individual elements.