php implode (101) with quotes
You could use array_map()
:
function add_quotes($str) {
return sprintf("'%s'", $str);
}
$csv = implode(',', array_map('add_quotes', $array));
DEMO
Also note that there is fputcsv
if you want to write to a file.
$array = array('lastname', 'email', 'phone');
echo "'" . implode("','", $array) . "'";