array_search找不到字符串


array_search not finding string?

$className = "Class B: Wednesday 6pm";
// $studentArray is multidimensional array with student info
foreach($studentArray as $student) {
    echo array_search($className,$student);
}
// Contents of $student is 
Array
(
    [Groups] => 187,267
    [Birthday] => DateTime Object
        (
            [date] => 1981-02-04 00:00:00.000000
            [timezone_type] => 3
            [timezone] => UTC
        )
    [_IGTestScore] => 0
    [Email] => blank@blank.com
    [_IGClass1] => Class B: Wednesday 6pm
    [_IGAttendedClass1] => DateTime Object
        (
            [date] => 2016-02-17 00:00:00.000000
            [timezone_type] => 3
            [timezone] => UTC
        )
    [FirstName] => Joe
    [Id] => 3
    [LastName] => Schmoe
)

其输出为:

_IGTestScore

如果我对$className进行var_dump并$student['_IGClass1],我会得到:

字符串(22) "B班:星期三下午6点"

字符串(22) "B班:星期三下午6点"

以前从未遇到过array_search问题,但这一直让我发疯,似乎无法弄清楚这里发生了什么。似乎任何字符串搜索都是一样的。但是如果我搜索一个整数,比如 3,它会正确拉出"Id"。

更新 - 整个多维数组

Array
(
    [0] => Array
        (
            [Groups] => 187,267
            [Birthday] => DateTime Object
                (
                    [date] => 1981-02-04 00:00:00.000000
                    [timezone_type] => 3
                    [timezone] => UTC
                )
            [_IGTestScore] => 0
            [Email] => blank@blank.com
            [_IGClass1] => Class B: Wednesday 6pm
            [_IGAttendedClass1] => DateTime Object
                (
                    [date] => 2016-02-17 00:00:00.000000
                    [timezone_type] => 3
                    [timezone] => UTC
                )
            [FirstName] => Joe
            [Id] => 3
            [LastName] => Schmoe
        )
)

我发现了问题...但我不知道原因:对我来说,这是一个谜!

问题_IGTestScore为整数:如果_IGTestScore是整数,array_search()返回_IGTestScore(实际上它为任何搜索字符串返回_IGTestScore,即使它们不存在!),如果_IGTestScore设置为'0'(字符串)或正整数,array_search()返回正确的值!

这是一个错误?

有人有解释吗?

编辑:

显然,有一个解决方案:使用"strict"参数:

array_search( $className, $student, True );

但。。。为什么是"B类:星期三下午6点"== 0?