回声冒号数组以表格式

时间:2016-04-25 20:39:10

标签: php html arrays html-table

我无法将冒号定义的数组转换为在表格中显示(如下所述)。任何人都可以指导我。

  resources :users, only: [:show, :index] do
    resources :characters do
      collection do
        get 'on_clan_change'
      end
    end
  end

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

enter image description here

1 个答案:

答案 0 :(得分:0)

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