Just something i cant understand why it does this or if i am getting something wrong.
I am trying to check if an array key == a sertain string in a foreach loop. this is what i have (only really simple, but... bugging me...)
foreach($option_arr as $key => $value){
echo $key; // this is just a test
if($key == "'Featured'"){
$featuredCheckCount++;
}
if($key == "'Home'"){
$homeCheckCount++;
}
}
The output for the echo $key is 'Featured' WITH the quotes. this is of course OK, but i would have expected the result to be without the quotes. it just makes the check for is == look messy by having to write it with the quotes.
if($key == "'Featured'") // with the quotes.
This is not really important, but i do like to understand why at time, rather than just accepting this.
I cant find an explanation on google, so any explanation would be welcomed. or a better way of doing this if i should be using something different.