[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-doc-cvs
Subject:    [DOC-CVS] [doc-en] master: Add note about how bad weak mode is for in_array
From:       Larry Garfield via GitHub <noreply () php ! net>
Date:       2022-08-25 11:49:47
Message-ID: X8D4ag8XatjBb9ub4tp1ZjXYMDz2BZ7jR4oqWs () main ! php ! net
[Download RAW message or body]

Author: Larry Garfield (Crell)
Committer: GitHub (web-flow)
Pusher: cmb69
Date: 2022-08-25T13:41:43+02:00

Commit: https://github.com/php/doc-en/commit/8cd7c0d8c574903e149c1da0689a8728cdf909d4
Raw diff: https://github.com/php/doc-en/commit/8cd7c0d8c574903e149c1da0689a8728cdf909d4.diff


Add note about how bad weak mode is for in_array

Closes GH-1768.

Changed paths:
  M  reference/array/functions/in-array.xml


Diff:

diff --git a/reference/array/functions/in-array.xml \
b/reference/array/functions/in-array.xml index 381c56a9671..936159ebd80 100644
--- a/reference/array/functions/in-array.xml
+++ b/reference/array/functions/in-array.xml
@@ -53,6 +53,14 @@
        <link linkend="language.types">types</link> of the
        <parameter>needle</parameter> in the <parameter>haystack</parameter>.
       </para>
+      <note>
+       <para>
+        Prior to PHP 8.0.0, a <literal>string</literal> \
<parameter>needle</parameter> will match an array +        value of \
<literal>0</literal> in non-strict mode, and vice versa.  That may lead to \
undesireable +        results.  Similar edge cases exist for other types, as well.  \
If not absolutely certain of the +        types of values involved, always use the \
<parameter>strict</parameter> flag to avoid unexpected behavior. +       </para>
+      </note>
      </listitem>
     </varlistentry>
    </variablelist>
@@ -152,6 +160,7 @@ if (in_array('o', $a)) {
    </example>
   </para>
  </refsect1>
+
  <refsect1 role="seealso">
   &reftitle.seealso;
   <para>

-- 
PHP Documentation Commits Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic