Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
动态设置为表头的PHP数组键_Php_Arrays - Fatal编程技术网

动态设置为表头的PHP数组键

动态设置为表头的PHP数组键,php,arrays,Php,Arrays,我将一组序列化的$\u POST数据存储到我的数据库中。获取并取消序列化后,数据表示为如下数组: Array ( [size] => 1359sf [buyfor] => Investment [budget] => 401,000-500,000 [fullname] => Chris Mark [age] => 36 [semail] => mark.c@hotmail.com [phone] =&g

我将一组序列化的
$\u POST
数据存储到我的数据库中。获取并取消序列化后,数据表示为如下数组:

Array
(
    [size] => 1359sf
    [buyfor] => Investment
    [budget] => 401,000-500,000
    [fullname] => Chris Mark
    [age] => 36
    [semail] => mark.c@hotmail.com
    [phone] => 6781822333
)
这些数组键是否可以动态设置为
,如下所示:

<table>
  <thead>
    <tr>
      <th>size</th>
      <th>buyfor</th>
      <th>budget</th>
      <th>fullname</th>
    </tr>
  </thead>

  ..looping recordset..

</table>
我只想选择
size
buyfor
budget
设置为


//固定收割台
第1栏
第2栏
//动态标题
大小
买断
预算
..循环记录集。。
您可以使用函数获取密钥

echo';
回声内爆(“”,$keys);
回声';

据我所知,您希望构建表的列标题,它将表示未序列化数组中的数据。如果是这种情况,则可以尝试如下循环槽阵列:

<table>
  <thead>
    <tr>
<?php
  foreach($array as $key=>$value) {
   echo "<th>".$key."</th>";
}

?>
</tr>
</table>

<table>
  <thead>
    <tr>
      //fixed header
      <th>column 1</th>
      <th>column 2</th>

      //dynamic header
      <th>size</th>
      <th>buyfor</th>
      <th>budget</th>
    </tr>
  </thead>

  ..looping recordset..

</table>
echo '<tr><th>';
echo implode('</th><th>', $keys);
echo '</th></tr>';
<table>
  <thead>
    <tr>
<?php
  foreach($array as $key=>$value) {
   echo "<th>".$key."</th>";
}

?>
</tr>
</table>