I'm trying to learn more about strings and arrays. I have this bit of code:
<?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.";
}
?>
According to my feeble mind, GA should exist in the array. If I put $exists = "OH", that works. But the screen is showing this:
Array ( [0] => OH [1] => VA [2] => GA )
GA doesn't exist.
What am I not understanding here?
var_dumpfor debugging.{}code tool to mark your code.