开发者

csv producing diff symbol

    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Content-Length: " . strlen($contents));
    // Output to browser with appropriate mime type, you choose开发者_开发问答 ;)
    header("Content-type: text/x-csv");
    header("Content-type: text/csv");
    header("Content-type: application/csv");
    header("Content-Disposition: attachment; filename=$filename");
    echo $contents;
    exit;

echo $contents; 
producing My Csv Output Look like this ,

also i pasted how i want

![alt text][1]


Ok, first things first:

Unless those sample images are bogus test data, DESTROY THEM NOW. It looks like you're exposing medical records, which puts you in violation of HIPAA. Drawing some downright moronic white X's through the text but leaving MOST OF IT EXPOSED is not "anonymization".

I hope it's testing data, you've got "testingPatientName" as a header, but still...

Second: you're outputting three different Content-type headers. Think of what you'd do if someone handed you a hamburger and said "this is a hotdog, and it's a steak, and it's a piece of celery". What were you just handed?

Third: Your code is just the necessary code to force a download of (apparently) .csv data, but you don't show how it's generated. How do you build your $content?

From the looks of your pictures, you've got some tab characters (or other 'seperator') in the header fields, but are using commas as the seperator for the actual data. Notice how the "James TWright III" record splits where you've got commas in the "i want it like this" sample. If you want to embed commas within a .csv field, you have to surround the field with double-quotes ("), and if the field contains double quotes, you have to double-double quote (""). e.g, given:

 This is a double quote "containing" field, with a comma

becomes

 "This is a double quote ""containing"" field, with a comma" 

within the .csv output.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜