我有这个数组格式,我从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
)
等
答案 0 :(得分: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);