reference/array/functions/in-array.xml
8cd7c0d8c574903e149c1da0689a8728cdf909d4
...
...
@@ -11,10 +11,11 @@
11
11
<type>bool</type><methodname>in_array</methodname>
12
12
<methodparam><type>mixed</type><parameter>needle</parameter></methodparam>
13
13
<methodparam><type>array</type><parameter>haystack</parameter></methodparam>
14
-
<methodparam choice="opt"><type>bool</type><parameter>strict</parameter></methodparam>
14
+
<methodparam choice="opt"><type>bool</type><parameter>strict</parameter><initializer>&false;</initializer></methodparam>
15
15
</methodsynopsis>
16
16
<para>
17
-
Searches <parameter>haystack</parameter> for <parameter>needle</parameter>.
17
+
Searches for <parameter>needle</parameter> in <parameter>haystack</parameter> using loose comparison
18
+
unless <parameter>strict</parameter> is set.
18
19
</para>
19
20
</refsect1>
20
21
<refsect1 role="parameters">
...
...
@@ -52,6 +53,14 @@
52
53
<link linkend="language.types">types</link> of the
53
54
<parameter>needle</parameter> in the <parameter>haystack</parameter>.
54
55
</para>
56
+
<note>
57
+
<para>
58
+
Prior to PHP 8.0.0, a <literal>string</literal> <parameter>needle</parameter> will match an array
59
+
value of <literal>0</literal> in non-strict mode, and vice versa. That may lead to undesireable
60
+
results. Similar edge cases exist for other types, as well. If not absolutely certain of the
61
+
types of values involved, always use the <parameter>strict</parameter> flag to avoid unexpected behavior.
62
+
</para>
63
+
</note>
55
64
</listitem>
56
65
</varlistentry>
57
66
</variablelist>
...
...
@@ -64,29 +73,6 @@
64
73
&false; otherwise.
65
74
</para>
66
75
</refsect1>
67
-
<refsect1 role="changelog">
68
-
&reftitle.changelog;
69
-
<para>
70
-
<informaltable>
71
-
<tgroup cols="2">
72
-
<thead>
73
-
<row>
74
-
<entry>&Version;</entry>
75
-
<entry>&Description;</entry>
76
-
</row>
77
-
</thead>
78
-
<tbody>
79
-
<row>
80
-
<entry>4.2.0</entry>
81
-
<entry>
82
-
<parameter>needle</parameter> may now be an array.
83
-
</entry>
84
-
</row>
85
-
</tbody>
86
-
</tgroup>
87
-
</informaltable>
88
-
</para>
89
-
</refsect1>
90
76
<refsect1 role="examples">
91
77
&reftitle.examples;
92
78
<para>
...
...
@@ -174,6 +160,7 @@ if (in_array('o', $a)) {
174
160
</example>
175
161
</para>
176
162
</refsect1>
163
+

177
164
<refsect1 role="seealso">
178
165
&reftitle.seealso;
179
166
<para>
180
167