reference/strings/functions/explode.xml
abd75f51f4daa22d471b0d14114df3886832fb6f
...
...
@@ -1,6 +1,6 @@
1
1
<?xml version="1.0" encoding="utf-8"?>
2
2
<!-- $Revision$ -->
3
-
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.explode">
3
+
<refentry xml:id="function.explode" xmlns="http://docbook.org/ns/docbook">
4
4
<refnamediv>
5
5
<refname>explode</refname>
6
6
<refpurpose>Split a string by a string</refpurpose>
...
...
@@ -10,14 +10,14 @@
10
10
&reftitle.description;
11
11
<methodsynopsis>
12
12
<type>array</type><methodname>explode</methodname>
13
-
<methodparam><type>string</type><parameter>delimiter</parameter></methodparam>
13
+
<methodparam><type>string</type><parameter>separator</parameter></methodparam>
14
14
<methodparam><type>string</type><parameter>string</parameter></methodparam>
15
-
<methodparam choice="opt"><type>int</type><parameter>limit</parameter><initializer>PHP_INT_MAX</initializer></methodparam>
15
+
<methodparam choice="opt"><type>int</type><parameter>limit</parameter><initializer><constant>PHP_INT_MAX</constant></initializer></methodparam>
16
16
</methodsynopsis>
17
17
<para>
18
18
Returns an array of strings, each of which is a substring of
19
19
<parameter>string</parameter> formed by splitting it on
20
-
boundaries formed by the string <parameter>delimiter</parameter>.
20
+
boundaries formed by the string <parameter>separator</parameter>.
21
21
</para>
22
22
</refsect1>
23
23

...
...
@@ -26,7 +26,7 @@
26
26
<para>
27
27
<variablelist>
28
28
<varlistentry>
29
-
<term><parameter>delimiter</parameter></term>
29
+
<term><parameter>separator</parameter></term>
30
30
<listitem>
31
31
<para>
32
32
The boundary string.
...
...
@@ -62,10 +62,9 @@
62
62
</para>
63
63
<note>
64
64
<para>
65
-
Although <function>implode</function> can, for historical reasons,
66
-
accept its parameters in either order,
67
-
<function>explode</function> cannot. You must ensure that the
68
-
<parameter>delimiter</parameter> argument comes before the
65
+
Prior to PHP 8.0, <function>implode</function> accepted its parameters in either order.
66
+
<function>explode</function> has never supported this: you must ensure that the
67
+
<parameter>separator</parameter> argument comes before the
69
68
<parameter>string</parameter> argument.
70
69
</para>
71
70
</note>
...
...
@@ -76,41 +75,45 @@
76
75
<para>
77
76
Returns an <type>array</type> of <type>string</type>s
78
77
created by splitting the <parameter>string</parameter> parameter on
79
-
boundaries formed by the <parameter>delimiter</parameter>.
78
+
boundaries formed by the <parameter>separator</parameter>.
80
79
</para>
81
80
<para>
82
-
If <parameter>delimiter</parameter> is an empty <type>string</type> (""),
83
-
<function>explode</function> will return &false;.
84
-
If <parameter>delimiter</parameter> contains a value that is not
81
+
If <parameter>separator</parameter> is an empty <type>string</type> (""),
82
+
<function>explode</function> throws a <classname>ValueError</classname>.
83
+
If <parameter>separator</parameter> contains a value that is not
85
84
contained in <parameter>string</parameter> and a negative
86
85
<parameter>limit</parameter> is used, then an empty <type>array</type> will be
87
86
returned, otherwise an <type>array</type> containing
88
-
<parameter>string</parameter> will be returned.
87
+
<parameter>string</parameter> will be returned. If <parameter>separator</parameter>
88
+
values appear at the start or end of <parameter>string</parameter>, said values
89
+
will be added as an empty <type>array</type> value either in the first or last
90
+
position of the returned <type>array</type> respectively.
89
91
</para>
90
92
</refsect1>
91
93

92
94
<refsect1 role="changelog">
93
95
&reftitle.changelog;
94
-
<para>
95
-
<informaltable>
96
-
<tgroup cols="2">
97
-
<thead>
98
-
<row>
99
-
<entry>&Version;</entry>
100
-
<entry>&Description;</entry>
101
-
</row>
102
-
</thead>
103
-
<tbody>
104
-
<row>
105
-
<entry>5.1.0</entry>
106
-
<entry>
107
-
Support for negative <parameter>limit</parameter>s was added
108
-
</entry>
109
-
</row>
110
-
</tbody>
111
-
</tgroup>
112
-
</informaltable>
113
-
</para>
96
+
<informaltable>
97
+
<tgroup cols="2">
98
+
<thead>
99
+
<row>
100
+
<entry>&Version;</entry>
101
+
<entry>&Description;</entry>
102
+
</row>
103
+
</thead>
104
+
<tbody>
105
+
<row>
106
+
<entry>8.0.0</entry>
107
+
<entry>
108
+
<function>explode</function> will now throw <classname>ValueError</classname>
109
+
when <parameter>separator</parameter> parameter is given an empty string
110
+
(<literal>""</literal>).
111
+
Previously, <function>explode</function> returned &false; instead.
112
+
</entry>
113
+
</row>
114
+
</tbody>
115
+
</tgroup>
116
+
</informaltable>
114
117
</refsect1>
115
118

116
119
<refsect1 role="examples">
...
...
@@ -190,7 +193,7 @@ $str = 'one|two|three|four';
190
193
// positive limit
191
194
print_r(explode('|', $str, 2));
192
195

193
-
// negative limit (since PHP 5.1)
196
+
// negative limit
194
197
print_r(explode('|', $str, -1));
195
198
?>
196
199
]]>
...
...
@@ -235,7 +238,6 @@ Array
235
238
</refsect1>
236
239

237
240
</refentry>
238
-

239
241
<!-- Keep this comment at the end of the file
240
242
Local variables:
241
243
mode: sgml
242
244