CSV file displaying value in different columns

298 Views Asked by At

I have an array $email_details and it is like this :

Array
(
    [email_address] => [email protected]
    [mail_client_friendly_name] => Apple iPhone iOS 7
)

I am trying to put this in CSV and doing the following code :

    header("Content-type: text/csv");
    header("Content-Disposition: attachment; filename=file.csv");
    $outputBuffer = fopen("php://output", 'w');
        foreach ($email_details as $email) {
            fputcsv($outputBuffer,$email); 
        }
        fclose($outputBuffer);

I am getting the CSV file here. But when I open it in open office or any other spreadsheet , the first part of second column is displayed along with first and the rest spawned across multiple columns. When I checked the o/p it is like the second column is wrapped inside double quotes. How can I show it in a single column

Here is a screen shot

enter image description here

The Apple iPhone iOs7 should come in one column. I mean first column should be the email ID and second column is the client name.

0

There are 0 best solutions below