php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67947 array_keys case-insensitive compare not work even if bool $strict false
Submitted: 2014-09-02 12:04 UTC Modified: 2014-09-02 17:16 UTC
From: rob_neal at rocketmail dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 5.5.16 OS: Windows 8.1
Private report: No CVE-ID: None
 [2014-09-02 12:04 UTC] rob_neal at rocketmail dot com
Description:
------------
Running PHP version 5.5.15 on XAMPP for Windows. This is latest version of XAMPP/PHP as of today's date.

Only changes to default php.ini that I have made are about Mail and XDebug for debugging with Komodo IDE.

Test script:
---------------
$arr = array('uuu', 'abc','aBC','ABC','abc', 'Def', 'DEF', 'xyz');

//set 3rd argument as $strict=false for case-insensitive
$k = array_keys($arr,'abc',false);

print_r($k);

Expected result:
----------------
Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 ) 

Actual result:
--------------
Array ( [0] => 1 [1] => 4 ) 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-09-02 16:34 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2014-09-02 16:34 UTC] requinix@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

$strict has nothing to do with case sensitivity.
 [2014-09-02 17:16 UTC] rob_neal at rocketmail dot com
Thank you for your reply. I now see that this is not a bug. In your reply you shared some useful information: "$strict has nothing to do with case sensitivity". Though the php docs need to be concise, it would be useful/helpful to add a short statement like that on all "strict" arguments for all functions with a link to learn more about exactly what "strict comparisons" mean and how it does not mean consideration of case-sensitivity.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 07:01:32 2024 UTC