Specific coditional usage [closed]

Here you go. Because the DL, DT, DD, and UL are all within the foreach loop, that is why they are being duplicated. Here is the proper code:

function get_spec_1(){
  $desc1 = get_post_meta( get_the_ID(), 'eco_mb_tp_1', true );

  if( !empty( $desc1 ) ){
    // Open the stuff
    $code = "
      <dl>
      <dt class="bullet6-top">General</dt>
      <dd>
      <ul>";
    // Loop through the items once inside the ul
    foreach ( $desc1 as $d1 ){
      code .="<li>$d1</li>";
    }
    // Close the stuff
    code.="
      </ul>
      </dd>
      </dl>
      ";
    echo $code;
  }
}