Hello,

I have an array that looks like this:
Code:
Array
(
    [0] => Array
        (
            [bandwidthlocalTime] => 1349617319
            [bandwidthTx] => 6
            [bandwidthRx] => 1
            [bandwidthAdapter] => eth0
            [bandwidthChannel] => 5sec
        )

    [1] => Array
        (
            [bandwidthlocalTime] => 1349617319
            [bandwidthTx] => 1
            [bandwidthRx] => 1
            [bandwidthAdapter] => ppp0
            [bandwidthChannel] => 5sec
        )

    [2] => Array
        (
            [bandwidthlocalTime] => 1349617325
            [bandwidthTx] => 2
            [bandwidthRx] => 3
            [bandwidthAdapter] => eth0
            [bandwidthChannel] => 5sec
        )

    [3] => Array
        (
            [bandwidthlocalTime] => 1349617325
            [bandwidthTx] => 3
            [bandwidthRx] => 3
            [bandwidthAdapter] => ppp0
            [bandwidthChannel] => 5sec
        )

    [4] => Array
        (
            [bandwidthlocalTime] => 1349617331
            [bandwidthTx] => 2
            [bandwidthRx] => 0
            [bandwidthAdapter] => eth0
            [bandwidthChannel] => 5sec
        )

    [5] => Array
        (
            [bandwidthlocalTime] => 1349617331
            [bandwidthTx] => 0
            [bandwidthRx] => 0
            [bandwidthAdapter] => ppp0
            [bandwidthChannel] => 5sec
        )
I need it to basically be like this:
Code:
Array
(
    [0] => Array
        (
            [bandwidthlocalTime] => 1349617319
            [bandwidthTx_eth0] => 6
            [bandwidthRx_eth0] => 1
            [bandwidthTx_ppp0] => 1
            [bandwidthRx_ppp0] => 1
            [bandwidthChannel] => 5sec
        )

    [1] => Array
        (
            [bandwidthlocalTime] => 1349617325
            [bandwidthTx_eth0] => 2
            [bandwidthRx_eth0] => 3
            [bandwidthTx_ppp0] => 3
            [bandwidthRx_ppp0] => 3
            [bandwidthChannel] => 5sec
        )

    [2] => Array
        (
            [bandwidthlocalTime] => 1349617331
            [bandwidthTx_eth0] => 2
            [bandwidthRx_eth0] => 0
            [bandwidthTx_ppp0] => 0
            [bandwidthRx_ppp0] => 0
            [bandwidthChannel] => 5sec
        )
Basically, it's pulling some data from a database out like in the first array. There is one entry for each adapter at the same time. I basically need to make the timestamp the primary dimension of the array (With no duplicates) and then have 'bandwidthTx' and 'bandwidthRx' with 'bandwidthAdapter' in the second dimension of the array. It is easy to do with some hard IF statements, but I can't seem to get my head around it with an unknown amount of adapters (There could be more then eth0 and ppp0 for example).

Here's my current code, but I'm fairly sure it's not close to being correct:
PHP Code:
$listLineStatsNumbers=getbwStatsNumbers();

foreach (
$listLineStatsNumbers as $listLineStatsNumbersIndexForAdapter => $listLineStatsNumbersValueForAdapter)
{
  
$adapterListFull[]=$listLineStatsNumbersValueForAdapter['bandwidthAdapter'];
}

$adapterList=array_unique($adapterListFull);

foreach (
$listLineStatsNumbers as $listLineStatsNumbersIndexForTime => $listLineStatsNumbersValueForTime)
{
  foreach (
$adapterList as $adapterListIndex => $adapterListValue)
  {
    
$dataToUse[$listLineStatsNumbersValueForTime['bandwidthlocalTime']]=array("bandwidthlocalTime" => $listLineStatsNumbersValueForTime['bandwidthlocalTime'], "bandwidthTx_" $adapterList[$adapterListIndex] => $listLineStatsNumbersValueForTime['bandwidthTx'],  "bandwidthRx_" $adapterList[$adapterListIndex] => $listLineStatsNumbersValueForTime['bandwidthRx']);
  }
  
$adapterListFull[]=$listLineStatsNumbersValueForTime['bandwidthAdapter'];
}

print_r ($unique);
$indexCounter=0;

foreach (
$dataToUse as $listLineStatsNumbersIndex => $listLineStatsNumbersValue)
{
  
$data[] = array(date("H:i:s",$listLineStatsNumbersValue['bandwidthlocalTime']),  $listLineStatsNumbersValue['bandwidthTx_' $listLineStatsNumbersValue["bandwidthAdapter"]],  $listLineStatsNumbersValue['bandwidthRx_' $listLineStatsNumbersValue["bandwidthAdapter"]]);
  
$indexCounter++;
  
//echo $listLineStatsNumbersValue['bandwidthTx_'] . $listLineStatsNumbersValue["bandwidthAdapter"]"";