You may try to force it like so:
$headers = array(
'"userid"',
'"fname"',
'"lname"'
);
By wrapping the values in actual quotes, and then just use a blank enclosure string:
$fp = fopen('data.csv', 'w+');
fputcsv($fp,$headers,',','');
fclose($fp);
To force it to exclude your quotes in the "needs to be enclosed" characters (PHP checks if the enclosure character is already inside the string, and escapes+encloses if necessary).
However, in new versions of PHP, you will get this error:
fputcsv(): enclosure must be a character
In which case, I would just recommend doing it yourself, like so:
function put_csv_headers($handle, $headers, $separator, $enclosure) {
// [add some error checks here, of course]
array_walk($headers, function(&$item, $i, $enc) {
$item = $enc . $item . $enc; // wrap the header with the enclosure
}, $enclosure);
fputs($handle, implode($separator, $headers));
}
And:
$headers = array('userid', 'fname', 'lname');
$fp = fopen('data.csv', 'w+');
put_csv_headers($fp, $headers, ',', '"');
fclose($fp);