Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/256.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP';s strcasecmp行为异常_Php - Fatal编程技术网

PHP';s strcasecmp行为异常

PHP';s strcasecmp行为异常,php,Php,下面是PHP代码 $input1 = array("a" => "green", "b" => "brown", "c" => "blue", "red"); $input2 = array("a" => "GREEN", "B" => "brown", "yellow", "RED"); $result = array_intersect_uassoc($input1, $input2, "strcasecmp"); print_r($result); 返回值

下面是PHP代码

$input1 = array("a" => "green", "b" => "brown", "c" => "blue", "red");
$input2 = array("a" => "GREEN", "B" => "brown", "yellow", "RED");

$result = array_intersect_uassoc($input1, $input2, "strcasecmp");
print_r($result);
返回值是多少

Array ( [b] => brown )

我想知道既然strcasecmp不区分大小写,为什么“绿色”和“绿色”不被认为是匹配的

你的误解不在于stracecmp,而在于array\u intersect\u uassoc。最后一个参数不用于比较值,而是用于比较键


因此,不区分大小写的检查不在值上,而是在键本身上,这就是“b”和“b”索引相交的原因。

您的误解不是在stracecmp上,而是在array_intersect_uassoc上。最后一个参数不用于比较值,而是用于比较键

因此,不区分大小写的检查不在值上,而是在键本身上,这就是“b”和“b”索引相交的原因