簡體   English   中英

如何在php中使用逗號分隔值創建html表單元格

[英]How to create a html table cell using comma separated value in php

我有幾個逗號分隔的值。我已將其添加到數組名稱“ meter_status”。我對其進行了分解,我想將這些數據添加到html表行中,以一種方式,我必須將其拆分並顯示

我嘗試了以下代碼。 但不是以td格式顯示可能是什么問題

$each=explode(',',$meter_status);
$count= count($each);
$status.='<td rowspan="'.$count.'">';

    foreach( $each as $link){
        $status.= $link;
    } 
$status.='</td>'; 
return $status;

嘗試這個 :

<?php
  $each=explode(',',$meter_status);
  $count= count($each); ?>
        $status.='<td rowspan="'.$count. '"'
  foreach( $each as $link){
        $status .= <<<TEXT 
            <tr>
                <td>$link</td>
             </tr>
TEXT;
      } 
    return $status;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM