note 120361 added to function.str-getcsv

From: Date: Wed, 21 Dec 2016 13:25:27 +0000
Subject: note 120361 added to function.str-getcsv
Groups: php.notes 
Request: Send a blank email to php-notes+get-208682@lists.php.net to get a copy of this message
how to solve the UTF-8 BOM's problem 如何处理UTF-8编码的CSV文件中的BOM问题 $bom =( chr(0xEF) . chr(0xBB) . chr(0xBF) ); //define bom $f = file_get_contents('a.csv'); //open the CSV file #$csv = str_getcsv($f); //it will have bom 这样会出现bom的问题 $csv = str_getcsv(str_replace($bom,'',$f)); //replace the bom 替换掉bom var_dump($csv); //dump 输出 ---- Server IP: 72.52.91.14 Probable Submitter: 113.68.114.186 ---- Manual Page -- http://php.net/manual/en/function.str-getcsv.php Edit -- https://master.php.net/note/edit/120361 Del: integrated -- https://master.php.net/note/delete/120361/integrated Del: useless -- https://master.php.net/note/delete/120361/useless Del: bad code -- https://master.php.net/note/delete/120361/bad+code Del: spam -- https://master.php.net/note/delete/120361/spam Del: non-english -- https://master.php.net/note/delete/120361/non-english Del: in docs -- https://master.php.net/note/delete/120361/in+docs Del: other reasons-- https://master.php.net/note/delete/120361 Reject -- https://master.php.net/note/reject/120361 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#208682) next »