mat*_*e64 6 php string split word-wrap
$strText = "The quick brown fox jumps over the lazy dog";
$arrSplit = str_split($strText, 12);
// result: array("The quick br","own fox jump","s over the l","azy dog");
// better: array("The quick","brown fox","jumps over the","lazy dog");
Run Code Online (Sandbox Code Playgroud)
Mic*_*ski 21
实际上wordwrap(),您可以使用 explode()换行符\n作为分隔符. explode()将在生成的换行符上拆分字符串wordwrap().
$strText = "The quick brown fox jumps over the lazy dog";
// Wrap lines limited to 12 characters and break
// them into an array
$lines = explode("\n", wordwrap($strText, 12, "\n"));
var_dump($lines);
array(4) {
[0]=>
string(9) "The quick"
[1]=>
string(9) "brown fox"
[2]=>
string(10) "jumps over"
[3]=>
string(12) "the lazy dog"
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9141 次 |
| 最近记录: |