我有一個字符串將一行字符串換行並且不在末尾添加換行符?
$str = 'aaaaabbbbbcccccdddddeeeeefffffggggghhhhhjjjjj';
$pos = 0;
$tmp = 0;
while($pos<strlen($str)) {
$tmp .= substr($str,$pos,5)."\n";
$pos += 5;
}
我不想在生產$str
aaaaa
bbbbb
ccccc
ddddd
eeeee
fffff
ggggg
hhhhh
jjjjj //No new line here
+1 short and sweet –