reference/strings/functions/substr-count.xml
45042fef652f1b4e904e809fcbfcf31f6c60670b
45042fef652f1b4e904e809fcbfcf31f6c60670b
...
...
@@ -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
...
...
@@ -75,7 +75,7 @@
75
75
<refsect1 role="returnvalues">
76
76
&reftitle.returnvalues;
77
77
<para>
78
-
This function returns an <type>integer</type>.
78
+
This function returns an <type>int</type>.
79
79
</para>
80
80
</refsect1>
81
81
...
...
@@ -91,6 +91,12 @@
91
91
</row>
92
92
</thead>
93
93
<tbody>
94
+
<row>
95
+
<entry>8.0.0</entry>
96
+
<entry>
97
+
<parameter>length</parameter> is nullable now.
98
+
</entry>
99
+
</row>
94
100
<row>
95
101
<entry>7.1.0</entry>
96
102
<entry>
...
...
@@ -113,23 +119,22 @@
113
119
<![CDATA[
114
120
<?php
115
121
$text = 'This is a test';
116
-
echo strlen($text); // 14
122
+
echo strlen($text), PHP_EOL; // 14
117
123
118
-
echo substr_count($text, 'is'); // 2
124
+
echo substr_count($text, 'is'), PHP_EOL; // 2
119
125
120
126
// the string is reduced to 's is a test', so it prints 1
121
-
echo substr_count($text, 'is', 3);
127
+
echo substr_count($text, 'is', 3), PHP_EOL;
122
128
123
129
// the text is reduced to 's i', so it prints 0
124
-
echo substr_count($text, 'is', 3, 3);
125
-
126
-
// generates a warning because 5+10 > 14
127
-
echo substr_count($text, 'is', 5, 10);
128
-
130
+
echo substr_count($text, 'is', 3, 3), PHP_EOL;
129
131
130
132
// prints only 1, because it doesn't count overlapped substrings
131
133
$text2 = 'gcdgcdgcd';
132
-
echo substr_count($text2, 'gcdgcd');
134
+
echo substr_count($text2, 'gcdgcd'), PHP_EOL;
135
+
136
+
// throws an exception because 5+10 > 14
137
+
echo substr_count($text, 'is', 5, 10), PHP_EOL;
133
138
?>
134
139
]]>
135
140
</programlisting>
...
...
@@ -149,7 +154,6 @@ echo substr_count($text2, 'gcdgcd');
149
154
</para>
150
155
</refsect1>
151
156
</refentry>
152
-
153
157
<!-- Keep this comment at the end of the file
154
158
Local variables:
155
159
mode: sgml
156
160