I got an array $data['permissions'] which looks like this: Array ( [0] => 2 [1] => 11 ) and my in_array function I wrote do not work. Here is the code:
$data['permissions'] = $auth_user->getPermissions();
$stmt = $auth_user->runQuery("SELECT * FROM words;");
$stmt->execute();
while($wordsRow=$stmt->fetch(PDO::FETCH_ASSOC)){
echo $wordsRow['subcategory_id'];?>
<tr>
<?php
if($wordsRow['user_id'] == $_SESSION['user_session'] ||
in_array(array($wordsRow['subcategory_id']), $data['permissions'])){ ?>
<td><?php echo $wordsRow['name'];?></td>
<td><?php echo $wordsRow['subcategory_id'];?></td>
<?php
}
?>
</tr>
<?php
}
$wordsRow['user_id'] == $_SESSION['user_session'] in if works fine but in_array function in if is not finding the value that actually is in this array.
echo $wordsRow['subcategory_id'];
in while loop shows: 11 2 11. Where is the problem?