在php中动态填充复选框

I am fetching Gmail contacts using OAuth API call in PHP and it's successfully done. But while trying to insert a checkbox with each email ID I am getting difficulties. Here is the snippet of the foreach loop where the email IDs are populated:

$temp = json_decode($xmlresponse, true);
$links = array();
foreach($temp['feed']['entry'] as $cnt) {
    $links[] = $cnt['gd$email']['0']['address'] . "</br>";
}
?>

<span><?php echo implode("
", $links); ?></span>
<input type="checkbox" name="links[]" value="<?php echo implode("
", $links); ?> /><br />

It displays the email IDs, but there is no checkbox displaying here. Can anyone please help me with this?

You need to create a checkbox input for each link item.

foreach($links as $link){
    //echoes the name of the id
    echo '<span>' . $link . '</span>';
    echo '<input type="checkbox" name="links[]" value="' . $link . '"/>';
}