I want to display all the category and I want to set selected properties to multiple Checkboxes.
<?php
$allCategories = $category->getAllCategory();
if ($allCategories) {
$categoryAccess = $category_permitted->getCategoriesByUserId($user_info[0]->id);
foreach ($allCategories as $key => $items) {
if ($categoryAccess) {
foreach ($categoryAccess as $key => $value) {
?>
<input type="checkbox" name="cat_access[]" value=" <?php echo $items->id ?> " <?php echo (isset($categoryAccess) && @$categoryAccess[$key]->id == $items->id) ? 'checked' : '' ?>><?php echo $items->title?>
<?php
}
}
?>
<?php
}
}
?>
After looping through $categoryAccess I got two options selected but I am getting all category repeating twice as an output i.e category1 category 1 category 2 category 2 category 3 category 3 category 4 category 4.
(Added [code]
tags ~ Mod)