0

I have a problem with my export.

So I tried to export data to .csv with the following code :

        $output = fopen('php://output', 'w');
        $sFileName = 'test.csv';
        header('Content-Disposition: attachement; filename="' . $sFileName . '";');
        header("Content-Type:application/csv;charset=UTF-8");
        fwrite($output, "sep=;\n");
        fputcsv($output, array('Nom', 'Prenom'), ";");
        foreach ($aFilterGifts as $value) {
            fputcsv($output, $value, ";");
        }
        fpassthru($output);
        fclose($output);
        exit;

Where the $aFilterGifts is an array with data. But If I have in Nom, data like this Fossé, when I export I get FossГ©.

Is there a solution? Thank you in advance.

1
  • Make sure your php document ist utf8 encoded. Commented Jun 2, 2015 at 11:35

1 Answer 1

1

I found the error, it's necessairy to make $output = fopen('php://output', 'w'); after all headers,so thhe code is like this :

    $sFileName = 'test.csv';
    header('Content-Disposition: attachement; filename="' . $sFileName . '";');
    header("Content-Type:application/csv;charset=UTF-8");
    $output = fopen('php://output', 'w');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.