Php 为什么可以';这不是很简单吗?

Php 为什么可以';这不是很简单吗?,php,Php,结果: $country='ID'; echo '$country:' . $country; echo "\n arCountry: "; print_r ($arCountry); echo "\n" . 'in_array($country,$arCountry): '; echo in_array($country,$arCountry); 显然,$arCountry包含ID 然而,在数组($country,$arCountry):只是空的如果你不想清理$arCountry中的数据,你

结果:

$country='ID';
echo '$country:' . $country;
echo "\n arCountry: ";
print_r ($arCountry);
echo "\n" . 'in_array($country,$arCountry): ';
echo in_array($country,$arCountry);
显然,
$arCountry
包含ID


然而,
在数组($country,$arCountry)
:只是空的

如果你不想清理
$arCountry
中的数据,你可以尝试将它映射到更有用的东西

$country:ID
 arCountry: Array
(
    [0] => UK
    [1] => 
US
    [2] => 
ID
)

in_array($country,$arCountry): 

我们能看一下arCountry的定义吗?在我看来,
$arCountry[2]
包含类似于
“\nID”
的内容,这肯定不是
“ID”
@l'l我不会去猜测游戏中的空白字符here@l“我会的,也许还可以。据我们所知,条目是
“\r\nID”
,这是正确的。问题是,有一个
in_array($country, array_map('trim', $arCountry))