1
0
mirror of https://github.com/php/doc-ru.git synced 2026-03-26 00:32:15 +01:00
Files
archived-doc-ru/reference/strings/functions/wordwrap.xml
Sergey Panteleev 6d43fd64d7 Исправление форматирования
[skip-spellcheck]
[skip-lint]
2022-12-27 03:42:36 +03:00

180 lines
5.0 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: e095023e408c8cb6378ae16bb6870343a3946919 Maintainer: shein Status: ready -->
<!-- Reviewed: no -->
<refentry xml:id="function.wordwrap" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>wordwrap</refname>
<refpurpose>Переносит строку по указанному количеству символов</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>string</type><methodname>wordwrap</methodname>
<methodparam><type>string</type><parameter>string</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>width</parameter><initializer>75</initializer></methodparam>
<methodparam choice="opt"><type>string</type><parameter>break</parameter><initializer>"\n"</initializer></methodparam>
<methodparam choice="opt"><type>bool</type><parameter>cut_long_words</parameter><initializer>&false;</initializer></methodparam>
</methodsynopsis>
<para>
Переносит строку по указанному количеству символов.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>string</parameter></term>
<listitem>
<para>
Входная строка.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>width</parameter></term>
<listitem>
<para>
Количество символов, по которым строка будет перенесена.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>break</parameter></term>
<listitem>
<para>
Символ переноса строки можно указать с помощью необязательного
параметра <parameter>break</parameter>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>cut_long_words</parameter></term>
<listitem>
<para>
Если параметр <parameter>cut_long_words</parameter> установлен в &true;,
строка всегда будет переноситься на указанной ширине <parameter>width</parameter>
или раньше. Поэтому, если исходная строка содержит слово длиннее заданной
ширины строки, то оно будет разорвано. (Смотрите второй пример). Если установлен в
&false;, функция не разделяет слово, даже если <parameter>width</parameter>
меньше длины слова.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Возвращает строку со вставленными символами переноса на указанной длине.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Пример использования <function>wordwrap</function></title>
<programlisting role="php">
<![CDATA[
<?php
$text = "The quick brown fox jumped over the lazy dog.";
$newtext = wordwrap($text, 20, "<br />\n");
echo $newtext;
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
The quick brown fox<br />
jumped over the lazy<br />
dog.
]]>
</screen>
</example>
<example>
<title>Пример использования <function>wordwrap</function></title>
<programlisting role="php">
<![CDATA[
<?php
$text = "A very long woooooooooooord.";
$newtext = wordwrap($text, 8, "\n", true);
echo "$newtext\n";
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
A very
long
wooooooo
ooooord.
]]>
</screen>
</example>
<example>
<title>Пример использования <function>wordwrap</function></title>
<programlisting role="php">
<![CDATA[
<?php
$text = "A very long woooooooooooooooooord. and something";
$newtext = wordwrap($text, 8, "\n", false);
echo "$newtext\n";
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
A very
long
woooooooooooooooooord.
and
something
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>nl2br</function></member>
<member><function>chunk_split</function></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->