我正在尝试更多地了解字符串和数组.我有这段代码:
<?php
$states = "OH, VA, GA";
$arrayStates = explode(",", $states);
$exists = "GA";
print_r($arrayStates);
if (in_array($exists, $arrayStates)){
echo "<br/>" . $exists . " " . "exists.";
} else {
echo "<br/>" . $exists . " " . "doesn't exist.";
}
?>
Run Code Online (Sandbox Code Playgroud)
根据我的软弱思想,GA应该存在于数组中.如果我把$ exists ="OH",那就行了.但屏幕显示:
Array ( [0] => OH [1] => VA [2] => GA )
Run Code Online (Sandbox Code Playgroud)
GA不存在.
我在这里不理解什么?