{"id":1493,"date":"2010-11-19T15:07:59","date_gmt":"2010-11-19T06:07:59","guid":{"rendered":"http:\/\/www.itblog.jp\/?p=1493"},"modified":"2010-11-19T15:07:59","modified_gmt":"2010-11-19T06:07:59","slug":"fgetcsv%e3%81%a7sjis%e3%81%ae%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%82%92%e5%8f%96%e3%82%8a%e8%be%bc%e3%82%80%e9%9a%9b%e3%81%ae%e3%80%81%e6%96%87%e5%ad%97%e5%8c%96%e3%81%91%e3%81%ae%e5%af%be%e5%87%a6","status":"publish","type":"post","link":"https:\/\/www.itblog.jp\/?p=1493","title":{"rendered":"fgetcsv\u3067SJIS\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u53d6\u308a\u8fbc\u3080\u969b\u306e\u3001\u6587\u5b57\u5316\u3051\u306e\u5bfe\u51e6\u6cd5"},"content":{"rendered":"<p>\u4ed5\u4e8b\u3067\u3001SJIS\u306eCSV\u30d5\u30a1\u30a4\u30eb\u3092PHP\uff0bMySQL\u3067\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u767b\u9332\u3092\u3059\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u66f8\u3044\u3066\u3044\u305f\u306e\u3067\u3059\u304c\u3001\u4f55\u6545\u304b\u4e00\u6587\u5b57\u76ee\u304c\u6587\u5b57\u5316\u3051\u3057\u3066\u6b63\u5e38\u306b\u767b\u9332\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u305a\u3002<\/p>\n<p>\u539f\u56e0\u3092\u8abf\u3079\u3066\u307f\u305f\u3089\u3001CSV\u304b\u3089\u53d6\u308a\u8fbc\u3080\u95a2\u6570\u3001fgetcsv\u306fSJIS\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u53d6\u308a\u8fbc\u3080\u969b\u306b\u3001\u30d0\u30b0\u304c\u3042\u308b\u3089\u3057\u3044\u3068\u306e\u3053\u3068\u3067\u3057\u305f\u3002<br \/>\n\u203b\u305d\u3053\u306b\u6c17\u304c\u4ed8\u304f\u306e\u306b\u6642\u9593\u304c\u304b\u304b\u308a\u307e\u3057\u305f\uff08\u6c57\uff09<\/p>\n<p>\u3057\u304b\u3057\u3001\u8272\u3005\u3068\u8abf\u3079\u305f\u3068\u3053\u308d\u7121\u4e8b\u89e3\u6c7a\u3057\u305f\u306e\u3067\u30e1\u30e2\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<p>\u4e0b\u8a18\u30b5\u30a4\u30c8\u3092\u53c2\u8003\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n<p><a href=\"https:\/\/yossy.iimp.jp\/wp\/?p=56\" target=\"_blank\">PHP5\u3067fgetcsv\u304c\u6b63\u5e38\u306b\u52d5\u4f5c\u3057\u306a\u3044<\/a><\/p>\n<p>\u4e0b\u8a18\u306e\u95a2\u6570\u3092\u5b9a\u7fa9\u3057\u3066\u3001fgetcsv\u3068\u540c\u3058\u3088\u3046\u306b\u4f7f\u3046\u3053\u3068\u3067\u3001\u89e3\u6c7a\u3057\u307e\u3057\u305f\u3002<\/p>\n<blockquote><p><?php\n    \/**\n     * \u30d5\u30a1\u30a4\u30eb\u30dd\u30a4\u30f3\u30bf\u304b\u3089\u884c\u3092\u53d6\u5f97\u3057\u3001CSV\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u51e6\u7406\u3059\u308b\n     * @param resource handle\n     * @param int length\n     * @param string delimiter\n     * @param string enclosure\n     * @return \u30d5\u30a1\u30a4\u30eb\u306e\u7d42\u7aef\u306b\u9054\u3057\u305f\u5834\u5408\u3092\u542b\u307f\u3001\u30a8\u30e9\u30fc\u6642\u306bFALSE\u3092\u8fd4\u3057\u307e\u3059\u3002\n     *\/\n    function fgetcsv_reg (&#038;$handle, $length = null, $d = ',', $e = '\"') {\n        $d = preg_quote($d);\n        $e = preg_quote($e);\n        $_line = \"\";\n        while ($eof != true) {\n            $_line .= (empty($length) ? fgets($handle) : fgets($handle, $length));\n            $itemcnt = preg_match_all('\/'.$e.'\/', $_line, $dummy);\n            if ($itemcnt % 2 == 0) $eof = true;\n        }\n        $_csv_line = preg_replace('\/(?:\\\\r\\\\n|[\\\\r\\\\n])?$\/', $d, trim($_line));\n        $_csv_pattern = '\/('.$e.'[^'.$e.']*(?:'.$e.$e.'[^'.$e.']*)*'.$e.'|[^'.$d.']*)'.$d.'\/';\n        preg_match_all($_csv_pattern, $_csv_line, $_csv_matches);\n        $_csv_data = $_csv_matches[1];\n        for($_csv_i=0;$_csv_i<count($_csv_data);$_csv_i++){\n            $_csv_data[$_csv_i]=preg_replace('\/^'.$e.'(.*)'.$e.'$\/s','$1',$_csv_data[$_csv_i]);\n            $_csv_data[$_csv_i]=str_replace($e.$e, $e, $_csv_data[$_csv_i]);\n        }\n        return empty($_line) ? false : $_csv_data;\n    }\n?><\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>\u4ed5\u4e8b\u3067\u3001SJIS\u306eCSV\u30d5\u30a1\u30a4\u30eb\u3092PHP\uff0bMySQL\u3067\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u767b\u9332\u3092\u3059\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u66f8\u3044\u3066\u3044\u305f\u306e\u3067\u3059\u304c\u3001\u4f55\u6545\u304b\u4e00\u6587\u5b57\u76ee\u304c\u6587\u5b57\u5316\u3051\u3057\u3066\u6b63\u5e38\u306b\u767b\u9332\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u305a\u3002 \u539f\u56e0\u3092\u8abf\u3079\u3066\u307f\u305f\u3089\u3001CSV\u304b\u3089\u53d6\u308a\u8fbc\u3080\u95a2\u6570\u3001fget [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-1493","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/www.itblog.jp\/index.php?rest_route=\/wp\/v2\/posts\/1493","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.itblog.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.itblog.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.itblog.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.itblog.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1493"}],"version-history":[{"count":1,"href":"https:\/\/www.itblog.jp\/index.php?rest_route=\/wp\/v2\/posts\/1493\/revisions"}],"predecessor-version":[{"id":1494,"href":"https:\/\/www.itblog.jp\/index.php?rest_route=\/wp\/v2\/posts\/1493\/revisions\/1494"}],"wp:attachment":[{"href":"https:\/\/www.itblog.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1493"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.itblog.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1493"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.itblog.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1493"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}