简体   繁体   English

如何在php中使用逗号分隔值创建html表单元格

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

I have few comma separated values .I have added it to an array name 'meter_status' .I exploded it I want to add these data to html table row ,in the way in one cell i have to split it and display it 我有几个逗号分隔的值。我已将其添加到数组名称“ meter_status”。我对其进行了分解,我想将这些数据添加到html表行中,以一种方式,我必须将其拆分并显示

I tried with the following code. 我尝试了以下代码。 But it is not display in td format what can be the issue 但不是以td格式显示可能是什么问题

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

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

Try this : 尝试这个 :

<?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