If the statement in the foreach loop does not work properly


I have a foreach loop with an if statement inside it so that if $value equals 'Messages' it should increment my variable num1 by 1, but the if statement doesn't appear to be working correctly. Any help would be greatly appreciated.

EDIT: If I get rid of the if statement and just echo $value, it will echo out the value of every section in the array.


     $num1 = 0;
     foreach($inventory['Category'] as $key => $value) {
         if ($value == 'Messages') {

The only reason $num1 is not increasing could be because $value is not 'Messages'. Try echoing $value variable & see.