Last active
February 26, 2019 10:44
-
-
Save mighty5/ea3e0ebe4ac18ae7be88 to your computer and use it in GitHub Desktop.
[PHP]マルチバイト対応のwordwrapが無いから作った ref: https://qiita.com/mighty5/items/a5e048046e6e662134a0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function mb_wordwrap( $str, $width=35, $break=PHP_EOL ) | |
{ | |
$c = mb_strlen($str); | |
$arr = []; | |
for ($i=0; $i<=$c; $i+=$width) { | |
$arr[] = mb_substr($str, $i, $width); | |
} | |
return implode($break, $arr); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment