문제

I have a csv file that contains double quotes. when I read it using php fgetcsv(), the fields contain quotation will retrun null:

while(($data=fgetcsv($handle,5000,'|'))!==false){
    echo $data[0];
}

and the csv file may look like this

25" H x 8" W |15" H x 5" W
17.5" H x 9" W | 5" H x 12" W

Could anybody give me some advices?

도움이 되었습니까?

해결책

fgetcsv() defaults to using a " as an enclosure character, but you can change this to another different character (e.g. a tilde ~) that isn't used anywhere in your data; then the " won't be misinterpreted

while(($data=fgetcsv($handle,5000,'|','~'))!==false){
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top