【问题标题】:Echo colon array in table format [closed]表格格式的回声冒号数组[关闭]
【发布时间】:2016-04-25 20:39:09
【问题描述】:

我无法将这个由冒号定义的数组转换为显示在表格中(如下所述)。谁能指导我。

$info='Title:Beckham,Age:43,Address:UK';  

必须看起来像这种表格格式:

【问题讨论】:

  • 逗号爆炸,循环,冒号爆炸
  • 我对研究的术语感到困惑,谢谢你帮助我。
  • 很高兴听到你得到帮助,你可以在我的答案上打勾,这样其他人也可以得到帮助。

标签: php html arrays html-table


【解决方案1】:
<?php
$info='Title:Beckham,Age:43,Address:UK'; 
$info_array = explode(",",$info); 
$table = "<table>";

foreach($info_array as $row){
    $row_obj_array = explode(":",$row);
    $table .= "<tr><td>$row_obj_array[0]</td><td>$row_obj_array[1]</td></tr>";
}

$table.="</table>";
echo $table;
?>

【讨论】:

  • Nirpendra,它有效。谢谢你帮助我。
猜你喜欢
  • 2019-09-06
  • 2021-05-11
  • 2010-11-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-04-05
  • 2015-02-27
相关资源
最近更新 更多