I have a variable and its type is string. var_dump() shows:
var_dump() output is below:
string(14)
//this is my code..
$game_cat = "Some text"; // some text mean actually it is one of below Category 1,2,3,4 ...
if ( $game_cat === "Category 1" ) {
$cid = 1;
}
if ( $game_cat === "Category 2" ) {
$cid = 2;
}
if ( $game_cat === "Category 3" ) {
$cid = 0;
}
else{
$cid = 999999;
}
For example when I change $game_cat to Category 1 like $game_cat = "Category 1"; $cid must 1 but output is 999999.
Why?
==, if that works, then the strings might be the same value, but not EXACTLY the same. Notice your string has 14 characters while "Category 1" has 10, 12 including the double quotes==and===. Double check that your capitalization is the same, and that you aren't appending extra spaces withtrim().