I'm outputting some groups in Wordpress, these display good. After I tick some checkboxes, all of these get up-to-date within the database properly. I'm also able to output what IDs that we are ticked inside a separate foreach loop but here's my problem, I have to test within the $groups as $category foreach loop whether an ID must be ticked, however i can't for that existence of me determine the logic!!

$categories = get_categories(); 
foreach($categories as $category)
    $eirepanel_general_options_string = implode(',', $eirepanel_general_options['checkbox']); // String
    $eirepanel_general_options_array_pieces = explode(',', $eirepanel_general_options_string); // Array of IDs

    echo $category->cat_ID; // String because inside loop


    <span><?php echo $category->cat_name; ?></span>
    <input name="eirepanel_general_options_checkbox[]" type="checkbox" value="<?php echo $category->cat_ID; ?>" />

If $ids consists of a listing of presently selected checkboxes, add this snippet for your <input type="checkbox"> line:

<input type="checkbox"... <?=in_array($category->cat_ID, $ids)? 'checked="checked"' : '' ?> ... >

$ids need to look like: array("25", "14", "1").