Req #60485 [Opn->Wfx]: in_array insensitive string comparison
| From: | cmb@php.net | Date: | Fri, 25 Jun 2021 11:56:35 +0000 |
| Subject: | Req #60485 [Opn->Wfx]: in_array insensitive string comparison | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-234631@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=60485&edit=1
ID: 60485
Updated by: cmb@php.net
Reported by: Hast4656 at gmail dot com
Summary: in_array insensitive string comparison
-Status: Open
+Status: Wont fix
Type: Feature/Change Request
Package: Arrays related
Operating System: linux
PHP Version: Irrelevant
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
This is unlikely to be implemented; a more general solution, i.e.
a function any() or some() has a better chance, but still would
need an RFC[1].
[1] <https://wiki.php.net/rfc/howto>
Previous Comments:
------------------------------------------------------------------------
[2011-12-30 04:19:31] phristen at yahoo dot com
How about adding a comparitor callback then?
Maybe even overload the third argument (e.g. if it's not a boolean, then assume callback), so
we can do something like:
in_array('a', array('A', 'b'), function($a, $b) { return
!strcasecmp($a, $b); });
------------------------------------------------------------------------
[2011-12-14 18:01:34] ppadron@php.net
Since in_array() handles different types, I don't think it would make sense to
add a parameter that is exclusive to handling strings.
------------------------------------------------------------------------
[2011-12-09 16:48:11] Hast4656 at gmail dot com
Description:
------------
Can you please add parameter for in_array that let this function to compare
strings insensitive?
Test script:
---------------
// something like
in_array('a', Array('a', 'A'), true, true);
// 4th bool param says should the function compare string in a case-sensitive manner or not
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=60485&edit=1