If statement in PHP
$karthik=$_POST['myarray1'];
var_dump($karthik);
if($karthik=="ALTA 3.1-06 (CLTA 123.2-06) - Zoning Classification and Allowable Uses - Improved Land "){
echo "correct";
}
else {
echo "incorrect";
}
am getting array value as "ALTA 3.1-06 (CLTA 123.2-06) - Zoning Classification and Allowable Uses - Improved Land"
but the result it is showing as incorrect i want to show it 开发者_如何学Cas a correct.
You got an extra space at the end of your string in the if statement.
because $karthik is an array, $karthik will equal array, you need to specify with a key which value out of the array you would like. I believe the easiest would be to try:
if($karthik[0] == "ALTA 3.1-06 (CLTA 123.2-06) - Zoning Classification and Allowable Uses - Improved Land "){
echo "correct";
}
else {
echo "incorrect";
}
I am not sure if the space at the end is required or not.
I noticed that you have a space attached to the end of
"ALTA 3.1-06 (CLTA 123.2-06) - Zoning Classification and Allowable Uses - Improved Land "
Maybe that's what is causing your error? You can always try trimming your strings.
You have an extra space at the end of your "ALTA [...] Improved Land " string.
try removing the extra space at the end of your hard coded string and use trim to remove any extra spaces i your POST variable
if(trim($karthik)=="ALTA 3.1-06 (CLTA 123.2-06) - Zoning Classification and Allowable Uses - Improved Land"){
echo "correct";
}
精彩评论