KEY and VALUE custom field issue

I don’t know if you can count on the order of both custom fields to be equal when returned from get_post_meta(), but if you can, you could use:

$links = get_post_meta($post->ID, 'links', false);
$URLs = get_post_meta($post->ID, 'URLs', false);
for ( $i = 0; $i < count( $links ); $i++ ) {
    if ( empty( $URLs[$i] ) ) {
        $URLs[$i] = '#';
    }
    echo '<div class="first-link bottom-dotted"><p><a href="'.$URLs[$i].'">'.$links[$i].'</a></p></div>';
}