I have this array format which I query from mysql database. This data which I query got some duplicate so I remove the duplicate. The resulting query is below in array format
[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
)
how can i output this kind of array using one of the value as key.
[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
)
etc.
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);