PHP: fputcsv
PHP has a function to format some input as a comma-separated sequence of values and write it to an open file handle.
It’s called fputcsv.
PHP does not have a function to perform this same operation without writing it to a file handle.