you can put:
function is_checked($val,$match)
{
if (trim($val) == trim($match))
return " CHECKED ";
}
<input type='radio' value='dog' name='pet' <?php echo is_checked($pet,'dog');?>>
<input type='radio' value='cat' name='pet' <?php echo is_checked($pet,'cat');?>>
<input type='radio' value='rabbit' name='pet' <?php echo is_checked($pet,'rabbit');?>>