1
0
mirror of https://github.com/php/doc-ru.git synced 2026-04-27 01:08:05 +02:00
Files
archived-doc-ru/reference/mbstring/functions/mb-strimwidth.xml
T
2021-03-16 12:38:23 +03:00

160 lines
5.2 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: 64f2f1c70d2f42507d9c624e09dcf486ceca7be5 Maintainer: tmn Status: ready -->
<!-- Reviewed: yes -->
<!-- $Revision$ -->
<refentry xml:id="function.mb-strimwidth" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>mb_strimwidth</refname>
<refpurpose>Получение строки, обрезанной до заданного размера</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>string</type><methodname>mb_strimwidth</methodname>
<methodparam><type>string</type><parameter>string</parameter></methodparam>
<methodparam><type>int</type><parameter>start</parameter></methodparam>
<methodparam><type>int</type><parameter>width</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>trim_marker</parameter><initializer>""</initializer></methodparam>
<methodparam choice="opt"><type class="union"><type>string</type><type>null</type></type><parameter>encoding</parameter><initializer>&null;</initializer></methodparam>
</methodsynopsis>
<para>
Обрезает строку (<type>string</type>) <parameter>string</parameter>
до длины <parameter>width</parameter> символов,
где символы половинной ширины считаются как <literal>1</literal>, а символы полной
ширины считаются как <literal>2</literal>.
Смотрите <link xlink:href="&url.unicode.reports.tr;11/">&url.unicode.reports.tr;11/</link>
для получения подробной информации о ширине символов Восточной Азии.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>string</parameter></term>
<listitem>
<para>
Исходная строка.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>start</parameter></term>
<listitem>
<para>
Смещение от начала строки. Количество символов от начала строки (первый символ стоит
в позиции 0). Если указано отрицательное число, то отсчёт будет идти с конца строки.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>width</parameter></term>
<listitem>
<para>
Размер вырезаемой части в символах. Отрицательные значения отсчитываются с конца.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>trim_marker</parameter></term>
<listitem>
<para>
Строка, которая заместит конец обрезанной строки.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>encoding</parameter></term>
<listitem>
&mbstring.encoding.parameter;
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Обрезанная строка. Если задан четвёртый аргумент <parameter>trim_marker</parameter>,
то его значением замещаются последние символы строки, так чтобы суммарный размер был не более
<parameter>width</parameter>.
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
&mbstring.changelog.encoding-nullable;
<row>
<entry>7.1.0</entry>
<entry>
Добавлена поддержка отрицательных <parameter>start</parameter> и
<parameter>width</parameter>.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Пример использования <function>mb_strimwidth</function></title>
<programlisting role="php">
<![CDATA[
<?php
echo mb_strimwidth("Hello World", 0, 10, "...");
// Выведет "Hello W..."
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>mb_strwidth</function></member>
<member><function>mb_internal_encoding</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
-->