{"id":3213,"date":"2022-04-30T16:57:21","date_gmt":"2022-04-30T07:57:21","guid":{"rendered":"https:\/\/blue-bear.jp\/kb\/?p=3213"},"modified":"2023-02-19T14:49:27","modified_gmt":"2023-02-19T05:49:27","slug":"php%e6%97%a5%e6%9c%ac%e8%aa%9e%e3%81%ae%e6%96%87%e5%ad%97%e6%95%b0%e3%81%a7wordwrap%e3%81%97%e3%81%a6%e6%8a%98%e3%82%8a%e8%bf%94%e3%81%99%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/blue-bear.jp\/kb\/php%e6%97%a5%e6%9c%ac%e8%aa%9e%e3%81%ae%e6%96%87%e5%ad%97%e6%95%b0%e3%81%a7wordwrap%e3%81%97%e3%81%a6%e6%8a%98%e3%82%8a%e8%bf%94%e3%81%99%e6%96%b9%e6%b3%95\/","title":{"rendered":"[PHP]\u65e5\u672c\u8a9e\u306e\u6587\u5b57\u6570\u3067wordwrap\u3057\u3066\u6298\u308a\u8fd4\u3059\u65b9\u6cd5"},"content":{"rendered":"\n<p>\u65e5\u672c\u8a9e\u306e\u6587\u5b57\u6570\u3067wordwrap\u3057\u3066\u6298\u308a\u8fd4\u3059\u95a2\u6570\u306f\u30d3\u30eb\u30c9\u30a4\u30f3\u3067\u306f\u306a\u3044\u305f\u3081\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306b\u81ea\u5206\u3067\u95a2\u6570\u3092\u5b9f\u88c5\u3059\u308b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function mb_wordwrap($string, $width=75, $break=\"\\n\", $cut = false) {\n    if (!$cut) {\n        $regexp = '#^(?:&#91;\\x00-\\x7F]|&#91;\\xC0-\\xFF]&#91;\\x80-\\xBF]+){'.$width.',}\\b#U';\n    } else {\n        $regexp = '#^(?:&#91;\\x00-\\x7F]|&#91;\\xC0-\\xFF]&#91;\\x80-\\xBF]+){'.$width.'}#';\n    }\n    $string_length = mb_strlen($string,'UTF-8');\n    $cut_length = ceil($string_length \/ $width);\n    $i = 1;\n    $return = '';\n    while ($i &lt; $cut_length) {\n        preg_match($regexp, $string, $matches);\n        $new_string = (!$matches ? $string : $matches&#91;0]);\n        $return .= $new_string.$break;\n        $string = substr($string, strlen($new_string));\n        $i++;\n    }\n    return $return.$string;\n}<\/code><\/pre>\n\n\n\n<p>\u4f7f\u3044\u65b9<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$story = mb_wordwrap($storyline, 21, '&lt;br\/>', true);<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u65e5\u672c\u8a9e\u306e\u6587\u5b57\u6570\u3067wordwrap\u3057\u3066\u6298\u308a<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[418,419],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts\/3213"}],"collection":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/comments?post=3213"}],"version-history":[{"count":2,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts\/3213\/revisions"}],"predecessor-version":[{"id":3386,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts\/3213\/revisions\/3386"}],"wp:attachment":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/media?parent=3213"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/categories?post=3213"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/tags?post=3213"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}