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.
Code:
<?php
$num1 = 0;
foreach($inventory['Category'] as $key => $value) {
if ($value == 'Messages') {
$num1++;
}
}
?>
var_dump()on `$inventory['Category'] to verify that any values are Messages first? Otherwise the code looks fine.array_count_valuesmight be of use to you.