根据数据库值勾选复选框

I'm updating some countries values into db table. All countries fetch from TBL_COUNTRY table. Then few countries store to another table. I'm using implode function to store multiple values. it works fine. it stored like this in my db table Afghanistan,Argentina,Austria,Bangladesh.

I have tried this code

           <?php
                $exp_str = explode(',', $model_availability);
                foreach($exp_str as $get_str)
                {
                    echo $get_str;
                }
            ?>

This above code return this output AfghanistanArgentinaAustriaBangladesh

How do I put tick on the checkbox based on this value?

            <?php
                $sql = "SELECT * FROM ".TBL_COUNTRY." ORDER BY country_name ASC";
                $exe = mysql_query($sql, $CN);
                while($r = mysql_fetch_array($exe))
                {   
            ?>
            <input type="checkbox" name="model_availability[]" value="<?=$r['country_name']?>" id="<?=$r['country_name']?>" />
            <label for="<?=$r['country_name']?>"><?=$r['country_name']?></label>
            <?php } ?>
<input type="checkbox" name="model_availability[]" value="<?=$r['country_name']?>" id="<?=$r['country_name']?>"<?=(in_array($r['country_name'],$model_availability)?" checked":"")?> />

//In the input box just add a checked attribute, you will get.

 " id="" checked = "true" />