reference/mbstring/functions/mb-strimwidth.xml
ca4b9d11a25fc9f8dde7561c504ed466ed1d6c63
...
...
@@ -10,14 +10,18 @@
10
10
&reftitle.description;
11
11
<methodsynopsis>
12
12
<type>string</type><methodname>mb_strimwidth</methodname>
13
-
<methodparam><type>string</type><parameter>str</parameter></methodparam>
13
+
<methodparam><type>string</type><parameter>string</parameter></methodparam>
14
14
<methodparam><type>int</type><parameter>start</parameter></methodparam>
15
15
<methodparam><type>int</type><parameter>width</parameter></methodparam>
16
-
<methodparam choice="opt"><type>string</type><parameter>trimmarker</parameter><initializer>&quot;&quot;</initializer></methodparam>
17
-
<methodparam choice="opt"><type>string</type><parameter>encoding</parameter><initializer>mb_internal_encoding()</initializer></methodparam>
16
+
<methodparam choice="opt"><type>string</type><parameter>trim_marker</parameter><initializer>""</initializer></methodparam>
17
+
<methodparam choice="opt"><type class="union"><type>string</type><type>null</type></type><parameter>encoding</parameter><initializer>&null;</initializer></methodparam>
18
18
</methodsynopsis>
19
19
<para>
20
-
Truncates <type>string</type> <parameter>str</parameter> to specified <parameter>width</parameter>.
20
+
Truncates <type>string</type> <parameter>string</parameter> to specified <parameter>width</parameter>,
21
+
where halfwidth characters count as <literal>1</literal>, and fullwidth
22
+
characters count as <literal>2</literal>.
23
+
See <link xlink:href="&url.unicode.reports.tr;11/">&url.unicode.reports.tr;11/</link>
24
+
for details regarding East Asian character widths.
21
25
</para>
22
26
</refsect1>
23
27

...
...
@@ -26,7 +30,7 @@
26
30
<para>
27
31
<variablelist>
28
32
<varlistentry>
29
-
<term><parameter>str</parameter></term>
33
+
<term><parameter>string</parameter></term>
30
34
<listitem>
31
35
<para>
32
36
The <type>string</type> being decoded.
...
...
@@ -38,7 +42,8 @@
38
42
<listitem>
39
43
<para>
40
44
The start position offset. Number of
41
-
characters from the beginning of string. (First character is 0)
45
+
characters from the beginning of string (first character is 0),
46
+
or if start is negative, number of characters from the end of the string.
42
47
</para>
43
48
</listitem>
44
49
</varlistentry>
...
...
@@ -47,11 +52,17 @@
47
52
<listitem>
48
53
<para>
49
54
The width of the desired trim.
55
+
If negative width is specified, count from the end of the string.
56
+
<note>
57
+
<para>
58
+
Passing negative width is deprecated as of PHP 8.3.0.
59
+
</para>
60
+
</note>
50
61
</para>
51
62
</listitem>
52
63
</varlistentry>
53
64
<varlistentry>
54
-
<term><parameter>trimmarker</parameter></term>
65
+
<term><parameter>trim_marker</parameter></term>
55
66
<listitem>
56
67
<para>
57
68
A string that is added to the end of string
...
...
@@ -72,11 +83,41 @@
72
83
<refsect1 role="returnvalues">
73
84
&reftitle.returnvalues;
74
85
<para>
75
-
The truncated <type>string</type>. If <parameter>trimmarker</parameter> is set,
76
-
<parameter>trimmarker</parameter> replaces the last chars to match the <parameter>width</parameter>.
86
+
The truncated <type>string</type>. If <parameter>trim_marker</parameter> is set,
87
+
<parameter>trim_marker</parameter> replaces the last chars to match the <parameter>width</parameter>.
77
88
</para>
78
89
</refsect1>
79
90

91
+
<refsect1 role="changelog">
92
+
&reftitle.changelog;
93
+
<informaltable>
94
+
<tgroup cols="2">
95
+
<thead>
96
+
<row>
97
+
<entry>&Version;</entry>
98
+
<entry>&Description;</entry>
99
+
</row>
100
+
</thead>
101
+
<tbody>
102
+
<row>
103
+
<entry>8.3.0</entry>
104
+
<entry>
105
+
Passing a negative <parameter>width</parameter> to
106
+
<function>mb_strimwidth</function> is now deprecated.
107
+
</entry>
108
+
</row>
109
+
&mbstring.changelog.encoding-nullable;
110
+
<row>
111
+
<entry>7.1.0</entry>
112
+
<entry>
113
+
Support for negative <parameter>start</parameter>s and <parameter>width</parameter>s has been added.
114
+
</entry>
115
+
</row>
116
+
</tbody>
117
+
</tgroup>
118
+
</informaltable>
119
+
</refsect1>
120
+

80
121
<refsect1 role="examples">
81
122
&reftitle.examples;
82
123
<para>
...
...
@@ -105,7 +146,6 @@ echo mb_strimwidth("Hello World", 0, 10, "...");
105
146
</refsect1>
106
147

107
148
</refentry>
108
-

109
149
<!-- Keep this comment at the end of the file
110
150
Local variables:
111
151
mode: sgml
112
152