Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in F:\OpenServer\domains\php-fusion.vveb.ws\includes\bbcodes\mail_bbcode_include.php on line 20
Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in F:\OpenServer\domains\php-fusion.vveb.ws\includes\bbcodes\mail_bbcode_include.php on line 21
Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in F:\OpenServer\domains\php-fusion.vveb.ws\includes\bbcodes\search_bbcode_include.php on line 39
PHP
<?php
// RU:
// Функция для записи текста в столбик определённой ширины знаков (используется изредка для заголовков)
// функция делит строку `$header` на несколько строк с помощью `<br>`,
// если длина слова превышает `$in_line=20`.
// Делит по пробелу и чёрточке.
// Предполагается, что в тексте нигде не встречается "(-|-=|=-|-)"
-
// EN:
// Function for writing text in a column of a certain width of characters (used occasionally for headings)
// the function divides the string `$ header` into several lines using` <br> `,
// if the length of the word exceeds $ in_line = 20.
// Divide by space and dot.
// It is assumed that the text does not occur anywhere "(-|-=|=-|-)"
-
if (!function_exists("br_text_by_strlen")) {
function br_text_by_strlen ($header, $in_line=20 , $exp = "(-|-=|=-|-)" ) {
$header = str_replace( " ", " ".$exp, $header );
$header = str_replace( "-", "-".$exp, $header );
$header_arr = explode($exp, $header);
$lenth=0;
foreach ( $header_arr as $ka=>$kv ) {
$lenth = $lenth+strlen($kv);
if ($lenth>$in_line) { $header_arr[$ka]="<br>".$kv; $lenth=0; }
}
return implode("", $header_arr);
}
}
-
-
// RU: как использовать
// EN: how to use
-
$header = " функция делит строку header на несколько строк с помощью <br>, если длина слова превышает in_line=20. Делит по пробелу и чёрточке. Предполагается, что в тексте нигде не встречается...";
echo br_text_by_strlen ($header);
?>
|
Добавить комментарий Пожалуйста, залогиньтесь для добавления комментария.
|
|
<a href="https://php-fusion.vveb.ws/php-fusion.php?id=6&lang=ru"></a>
[url=https://php-fusion.vveb.ws/php-fusion.php?id=6&lang=ru][/url]
|