<?php
$array = array('lastname', 'email', 'phone');
$comma_separated = implode(",", $array);
echo $comma_separated;
//OR
$array = array('lastname', 'email', 'phone');
$comma_separated = join(",", $array);
echo $comma_separated;
// lastname,email,phone
/*
The implode() method is an inbuilt function in PHP and is used to join
the elements of an array.
The implode() method is an alias for PHP |
join() function and works exactly same as that of join() function.
*/
?>