0

我有从 mysql 数据库查询的这种数组格式。我查询的这个数据有一些重复,所以我删除了重复。结果查询以数组格式显示在下面

[0] => a
[1] => b


[2] => Array
    (
        [ch] => a
        [op] => 1
        [in] => 2012-12-20 09:28:53
    )

[3] => Array
    (
        [ch] => b
        [op] => 2
        [in] => 2012-12-20 19:44:10
    )


[4] => Array
    (
        [ch] => a
        [op] => 1000
        [in] => 2012-12-23 18:21:40
    )

[5] => Array
    (
        [ch] => b
        [op] => 1000
        [in] => 2012-12-23 18:26:16
    )



[6] => Array
    (
        [ch] => a
        [op] => 1000
        [in] => 2012-12-24 12:10:55
    )

我如何使用其中一个值作为键来输出这种数组。

[a] => array(
[op] => 1000
[in] => 2012-12-24 12:10:55
      ),
Array
(
[op] => 1000
[in] => 2012-12-23 18:21:40
    )
[b]=> Array
    (
        [op] => 1000
        [in] => 2012-12-23 18:26:16
    )

等等

4

1 回答 1

0
simply use array_push function,first define a blank array and grt value in it using array_push
eg.
$final_arr=array();
data=mysql_fetch_assoc($query);
array_push($final_arr,$data);
于 2013-04-02T04:33:31.033 回答