reference/strings/functions/substr-count.xml
e095023e408c8cb6378ae16bb6870343a3946919
...
...
@@ -1,7 +1,7 @@
1
1
<?xml version="1.0" encoding="utf-8"?>
2
2
<!-- $Revision$ -->
3
3
<!-- splitted from ./en/functions/strings.xml, last change in rev 1.27 -->
4
-
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.substr-count">
4
+
<refentry xml:id="function.substr-count" xmlns="http://docbook.org/ns/docbook">
5
5
<refnamediv>
6
6
<refname>substr_count</refname>
7
7
<refpurpose>Count the number of substring occurrences</refpurpose>
...
...
@@ -13,7 +13,7 @@
13
13
<methodparam><type>string</type><parameter>haystack</parameter></methodparam>
14
14
<methodparam><type>string</type><parameter>needle</parameter></methodparam>
15
15
<methodparam choice="opt"><type>int</type><parameter>offset</parameter><initializer>0</initializer></methodparam>
16
-
<methodparam choice="opt"><type>int</type><parameter>length</parameter></methodparam>
16
+
<methodparam choice="opt"><type class="union"><type>int</type><type>null</type></type><parameter>length</parameter><initializer>&null;</initializer></methodparam>
17
17
</methodsynopsis>
18
18
<para>
19
19
<function>substr_count</function> returns the number of times the
...
...
@@ -52,7 +52,8 @@
52
52
<term><parameter>offset</parameter></term>
53
53
<listitem>
54
54
<para>
55
-
The offset where to start counting
55
+
The offset where to start counting. If the offset is negative, counting
56
+
starts from the end of the string.
56
57
</para>
57
58
</listitem>
58
59
</varlistentry>
...
...
@@ -63,6 +64,7 @@
63
64
The maximum length after the specified offset to search for the
64
65
substring. It outputs a warning if the offset plus the length is
65
66
greater than the <parameter>haystack</parameter> length.
67
+
A negative length counts from the end of <parameter>haystack</parameter>.
66
68
</para>
67
69
</listitem>
68
70
</varlistentry>
...
...
@@ -73,7 +75,7 @@
73
75
<refsect1 role="returnvalues">
74
76
&reftitle.returnvalues;
75
77
<para>
76
-
This function returns an <type>integer</type>.
78
+
This function returns an <type>int</type>.
77
79
</para>
78
80
</refsect1>
79
81

...
...
@@ -89,11 +91,17 @@
89
91
</row>
90
92
</thead>
91
93
<tbody>
94
+
<row>
95
+
<entry>8.0.0</entry>
96
+
<entry>
97
+
<parameter>length</parameter> is nullable now.
98
+
</entry>
99
+
</row>
92
100
<row>
93
-
<entry>5.1.0</entry>
101
+
<entry>7.1.0</entry>
94
102
<entry>
95
-
Added the <parameter>offset</parameter> and
96
-
the <parameter>length</parameter> parameters
103
+
Support for negative <parameter>offset</parameter>s and <parameter>length</parameter>s has been added.
104
+
<parameter>length</parameter> may also be <literal>0</literal> now.
97
105
</entry>
98
106
</row>
99
107
</tbody>
...
...
@@ -147,7 +155,6 @@ echo substr_count($text2, 'gcdgcd');
147
155
</para>
148
156
</refsect1>
149
157
</refentry>
150
-

151
158
<!-- Keep this comment at the end of the file
152
159
Local variables:
153
160
mode: sgml
154
161