{"id":1888,"date":"2026-01-15T19:30:51","date_gmt":"2026-01-15T10:30:51","guid":{"rendered":"https:\/\/clouds.tokyo\/blog\/?p=1888"},"modified":"2026-01-15T19:30:51","modified_gmt":"2026-01-15T10:30:51","slug":"php_bom_remove","status":"publish","type":"post","link":"https:\/\/clouds.tokyo\/blog\/php_bom_remove\/","title":{"rendered":"PHP\u3067\u30d5\u30a1\u30a4\u30eb\u306bBOM\u304c\u3064\u3044\u3066\u3044\u305f\u3089\u524a\u9664\u3059\u308b"},"content":{"rendered":"<pre>\r\n\/\/ BOM\u304c\u3064\u3044\u3066\u3044\u305f\u3089BOM\u3092\u524a\u9664\u3057\u3066\u4fdd\u5b58\r\n$filepath = 'hoge.csv';\r\n$contents = file_get_contents($filepath);\r\n$bom = pack('H*','EFBBBF');\r\nif(substr($contents, 0, 3) === $bom) {\r\n  $contents = substr($contents, 3);\r\n  file_put_contents($filepath, $contents);\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\/\/ BOM\u304c\u3064\u3044\u3066\u3044\u305f\u3089BOM\u3092\u524a\u9664\u3057\u3066\u4fdd\u5b58 $filepath = &#8216;hoge.csv&#8217;; $contents = file_get_contents($filepath); $bom = pack(&#8216;H*&#8217;,&#8217;EF &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/clouds.tokyo\/blog\/php_bom_remove\/\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;PHP\u3067\u30d5\u30a1\u30a4\u30eb\u306bBOM\u304c\u3064\u3044\u3066\u3044\u305f\u3089\u524a\u9664\u3059\u308b&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"_jetpack_newsletter_access":""},"categories":[2],"tags":[72,96,355,370],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pezW3u-us","jetpack-related-posts":[{"id":894,"url":"https:\/\/clouds.tokyo\/blog\/excel_utf8\/","url_meta":{"origin":1888,"position":0},"title":"\u3010Excel\u3011UTF-8\u306eCSV\u3092Excel\u3067\u958b\u304f\u306b\u306f","author":"yamamoto","date":"2017\u5e7411\u670828\u65e5","format":false,"excerpt":"UTF-8\u306eCSV\u30d5\u30a1\u30a4\u30eb\u3092Excel\u3067\u958b\u304f\u3068\u3001\u305d\u306e\u307e\u307e\u3060\u3068\u6587\u5b57\u5316\u3051\u3057\u3066\u3057\u307e\u3044\u307e\u3059\u304c \u300cBOM\u3064\u304d\u300d\u2026","rel":"","context":"\u5099\u5fd8\u9332","block_context":{"text":"\u5099\u5fd8\u9332","link":"https:\/\/clouds.tokyo\/blog\/category\/memo\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":217,"url":"https:\/\/clouds.tokyo\/blog\/php_csv_read\/","url_meta":{"origin":1888,"position":1},"title":"\u3010PHP\u3011CSV\u30d5\u30a1\u30a4\u30eb\u306e\u8aad\u307f\u8fbc\u307f","author":"yamamoto","date":"2008\u5e742\u67084\u65e5","format":false,"excerpt":"\u3044\u308d\u3093\u306a\u65b9\u6cd5\u304c\u3042\u308b\u304b\u3068\u601d\u3044\u307e\u3059\u304c\u3001 str_getcsv() \u3092\u4f7f\u3063\u305f\u65b9\u6cd5\u3067\u3059\u3002 function \u2026","rel":"","context":"\u5099\u5fd8\u9332","block_context":{"text":"\u5099\u5fd8\u9332","link":"https:\/\/clouds.tokyo\/blog\/category\/memo\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":506,"url":"https:\/\/clouds.tokyo\/blog\/php_fgc_stat\/","url_meta":{"origin":1888,"position":2},"title":"\u3010PHP\u3011file_get_contents\u306e\u30a8\u30e9\u30fc\u51e6\u7406","author":"yamamoto","date":"2007\u5e7411\u670813\u65e5","format":false,"excerpt":"file_get_contents\u306f\u30d5\u30a1\u30a4\u30eb\u53d6\u5f97\u3060\u3051\u3067\u306a\u304f\u3001\u4ed6\u306e\u30b5\u30a4\u30c8\u306eAPI\u3092\u30b3\u30fc\u30eb\u3057\u305f\u308a\u3059\u308b\u3068\u304d\u2026","rel":"","context":"\u5099\u5fd8\u9332","block_context":{"text":"\u5099\u5fd8\u9332","link":"https:\/\/clouds.tokyo\/blog\/category\/memo\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1467,"url":"https:\/\/clouds.tokyo\/blog\/php-scrap\/","url_meta":{"origin":1888,"position":3},"title":"\u3010PHP\u3011PHP\u3067\u7c21\u5358\u306b\u30b9\u30af\u30ec\u30a4\u30d4\u30f3\u30b0","author":"yamamoto","date":"2022\u5e743\u670816\u65e5","format":false,"excerpt":"phpQuery\u3068\u3044\u3046\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u4f7f\u3048\u3070 PHP\u3067\u3082\u975e\u5e38\u306b\u7c21\u5358\u306b\u30b9\u30af\u30ec\u30a4\u30d4\u30f3\u30b0\u3067\u304d\u307e\u3059\u3002 phpQu\u2026","rel":"","context":"\u5099\u5fd8\u9332","block_context":{"text":"\u5099\u5fd8\u9332","link":"https:\/\/clouds.tokyo\/blog\/category\/memo\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":215,"url":"https:\/\/clouds.tokyo\/blog\/php_dl_header\/","url_meta":{"origin":1888,"position":4},"title":"\u3010PHP\u3011\u30d5\u30a1\u30a4\u30eb\u3092\u51fa\u529b\u3059\u308b\u3068\u304d\u306eheader","author":"yamamoto","date":"2010\u5e741\u67088\u65e5","format":false,"excerpt":"\u30d5\u30a1\u30a4\u30eb\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3055\u305b\u308b\u5834\u5408\u306b\u306f header\u3092\u8a18\u8ff0\u3057\u3066\u304b\u3089\u30d5\u30a1\u30a4\u30eb\u5185\u5bb9\u3092\u51fa\u529b\u3057\u307e\u3059\u3002 head\u2026","rel":"","context":"\u5099\u5fd8\u9332","block_context":{"text":"\u5099\u5fd8\u9332","link":"https:\/\/clouds.tokyo\/blog\/category\/memo\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":192,"url":"https:\/\/clouds.tokyo\/blog\/php_setlocale\/","url_meta":{"origin":1888,"position":5},"title":"\u3010PHP\u3011\u65e5\u672c\u8a9e\u306eCSV\u304c\u8aad\u307f\u53d6\u308c\u306a\u3044\u3068\u304d\u306b","author":"yamamoto","date":"2008\u5e748\u67087\u65e5","format":false,"excerpt":"\u30b5\u30fc\u30d0\u30fc\u3084\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3068\u540c\u3058\u6587\u5b57\u30b3\u30fc\u30c9\uff08UTF-8\uff09\u306a\u306e\u306b\u65e5\u672c\u8a9e\u306eCSV\u30d5\u30a1\u30a4\u30eb\u304c\u8aad\u307f\u53d6\u308c\u306a\u3044 \u3068\u3044\u2026","rel":"","context":"\u5099\u5fd8\u9332","block_context":{"text":"\u5099\u5fd8\u9332","link":"https:\/\/clouds.tokyo\/blog\/category\/memo\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/clouds.tokyo\/blog\/wp-json\/wp\/v2\/posts\/1888"}],"collection":[{"href":"https:\/\/clouds.tokyo\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/clouds.tokyo\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/clouds.tokyo\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/clouds.tokyo\/blog\/wp-json\/wp\/v2\/comments?post=1888"}],"version-history":[{"count":1,"href":"https:\/\/clouds.tokyo\/blog\/wp-json\/wp\/v2\/posts\/1888\/revisions"}],"predecessor-version":[{"id":1889,"href":"https:\/\/clouds.tokyo\/blog\/wp-json\/wp\/v2\/posts\/1888\/revisions\/1889"}],"wp:attachment":[{"href":"https:\/\/clouds.tokyo\/blog\/wp-json\/wp\/v2\/media?parent=1888"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/clouds.tokyo\/blog\/wp-json\/wp\/v2\/categories?post=1888"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/clouds.tokyo\/blog\/wp-json\/wp\/v2\/tags?post=1888"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}