I've been breaking my head over this problem all day. How can I transform the following array:
Array
(
[0] => Array
(
[compId] => 3081
[category] => Products
[rev] => 0.61
)
[1] => Array
(
[compId] => 3080
[category] => Plants
[rev] => 51
)
[2] => Array
(
[compId] => 3080
[category] => Products
[rev] => 6.1
)
)
Into an array with this format:
Array(
'compId'=>array("3081","3080"),
'Products'=>array('0.61', '6.1'),
'Plants'=>array('0', '51')
);
The former is being returned by a function. Please note that the 0 in the latter array isn't there in the former array. I do however need to preserve the key values. I've been trying several array functions to make it work but I just cant seem to solve the problem. Any help would be very much appreciated.
Let me try elaborating a bit. The latter array is used as input to create a table. The table would look like something as:
CompID | Products | Plants __________________________ 3081 | 0.61 | 0 __________________________ 3080 | 6.1 | 51