| 1 |
<? |
<?php |
| 2 |
function str_length(string $str) : string |
function str_length(string $str) : string |
| 3 |
{ |
{ |
| 4 |
$len = strlen($str); |
$len = strlen($str); |
| 38 |
{ |
{ |
| 39 |
return $str; |
return $str; |
| 40 |
} |
} |
| 41 |
|
|
| 42 |
$result = ""; |
$result = ""; |
| 43 |
$len = strlen($str); |
$len = strlen($str); |
| 44 |
$prefix_len = str_length($prefix); |
$prefix_len = str_length($prefix); |
| 56 |
{ |
{ |
| 57 |
continue; |
continue; |
| 58 |
} |
} |
| 59 |
|
|
| 60 |
if ($c == "\n") |
if ($c == "\n") |
| 61 |
{ |
{ |
| 62 |
if ($lines_count + 1 >= $lines_limit) |
if ($lines_count + 1 >= $lines_limit) |
| 104 |
$line_len++; |
$line_len++; |
| 105 |
} |
} |
| 106 |
|
|
| 107 |
$line .= $c; |
if ($line_len > $width) |
|
|
|
|
if ($line_len >= $width) |
|
| 108 |
{ |
{ |
| 109 |
if ($lines_count + 1 >= $lines_limit) |
if ($lines_count + 1 >= $lines_limit) |
| 110 |
{ |
{ |
| 114 |
$result .= ($line . $end_of_line); |
$result .= ($line . $end_of_line); |
| 115 |
$lines_count++; |
$lines_count++; |
| 116 |
$line = $prefix; |
$line = $prefix; |
| 117 |
$line_len = $prefix_len; |
$line_len = $prefix_len + 1; |
| 118 |
} |
} |
| 119 |
|
|
| 120 |
|
$line .= $c; |
| 121 |
} |
} |
| 122 |
|
|
| 123 |
if ($lines_count < $lines_limit) |
if ($lines_count < $lines_limit) |