-2

我有这个功能:

function remove_addresse($input) {
    if (!is_array ($input)) {
        $input = array ($input);
    }

    foreach ($this -> message_meta['to_address'] as $key => $address) {
        echo $address;
        print_r($input);
        if (in_array ($address, $input)) {
            unset ($this -> message_meta['to_address'][$key]);
       }
    }
}

由于某种原因 in_array 总是返回 false。

典型的$地址:mult3@client.com

典型的$输入:Array ( [0] => mult1.client.com [1] => mult3.client.com )

为什么会这样?

4

3 回答 3

0

mult3@client.com不等于mult3.client.com,所以你应该有false

于 2013-08-05T09:09:40.987 回答
0

除非 . 是典型输入中的错字,那么针不在大海捞针中。

mult3@client.com != mult3.client.com

于 2013-08-05T09:10:21.590 回答
0

正如其他人指出的那样,点与@符号不匹配。in_array() 使用直接匹配,没有正则表达式(因此没有占位符)。

于 2013-08-05T09:13:11.137 回答