--- fenglin/lib/str_process.inc.php 2025/03/24 05:46:49 1.11 +++ fenglin/lib/str_process.inc.php 2025/05/19 01:48:57 1.19 @@ -1,12 +1,47 @@ -= $lines_limit) + { + break; + } + + $result .= ($line . $end_of_line); $lines_count++; $line = $prefix; $line_len = $prefix_len; @@ -47,7 +87,12 @@ function split_line($str, $prefix = "", // Each UTF-8 CJK character should use two character length for display if ($line_len + 2 > $width) { - $result .= ($line . "\n"); + if ($lines_count + 1 >= $lines_limit) + { + break; + } + + $result .= ($line . $end_of_line); $lines_count++; $line = $prefix; $line_len = $prefix_len; @@ -59,15 +104,20 @@ function split_line($str, $prefix = "", $line_len++; } - $line .= $c; - - if ($line_len >= $width) + if ($line_len > $width) { - $result .= ($line . "\n"); + if ($lines_count + 1 >= $lines_limit) + { + break; + } + + $result .= ($line . $end_of_line); $lines_count++; $line = $prefix; - $line_len = $prefix_len; + $line_len = $prefix_len + 1; } + + $line .= $c; } if ($lines_count < $lines_limit) @@ -77,4 +127,3 @@ function split_line($str, $prefix = "", return $result; } -?>