Php数组剥离出html

时间:2016-09-02 05:08:57

标签: php

如果我不使用implode我的html标签不显示。为什么?我应该在数组中使用什么,这样才不会发生?

if( get_field('additional_specifications') ) {
    while ( have_rows('additional_specifications') ) : the_row();
    $addSpec[] = '<tr><td>' . get_sub_field('spec_name') . '</td><td>' . get_sub_field('spec_value') . '</td></tr>'; 

endwhile;
    $spec= implode($addSpec);

$content .=  $spec; 
}

if ($content) {
echo '<table class="spec-table">',$content,'</table>';
}

1 个答案:

答案 0 :(得分:0)

if( get_field('additional_specifications') ) {
    while ( have_rows('additional_specifications') ) : the_row();
        $content .= '<tr><td>' . get_sub_field('spec_name') . '</td><td>' . get_sub_field('spec_value') . '</td></tr>'; 
endwhile;

}

if ($content) {
    echo '<table class="spec-table">'. $content .'</table>';
 }
 ?>