splitting arrays
Posted: Thu Mar 22, 2012 5:17 am
I have an array which contains a list of databases, similar to the following:
[text]$ListDBArray
[$groupID]
[$dbID] [$Item] => Value[/text]
which prints out the following
I am then trying to break this into individual arrays, based on the groupID, so I would get something like:
I'm sure that this must be quite straightforward, but I can't for the life of me get my head around how to do this.
[text]$ListDBArray
[$groupID]
[$dbID] [$Item] => Value[/text]
which prints out the following
Code: Select all
Array (
[1] => Array (
[0] => Array ( [database] => Slave 1 [dbGroup] => 1 [IO] => Yes [SQL] => Yes [Seconds] => 0 [Last_Error] => )
[1] => Array ( [database] => Slave 2 [dbGroup] => 1 [IO] => Yes [SQL] => Yes [Seconds] => 0 [Last_Error] => ) )
[2] => Array (
[2] => Array ( [database] => A Slave [dbGroup] => 2 [IO] => Yes [SQL] => Yes [Seconds] => 0 [Last_Error] => )
[3] => Array ( [database] => O Slave [dbGroup] => 2 [IO] => Yes [SQL] => Yes [Seconds] => 0 [Last_Error] => )
)
)Code: Select all
//Group ID 1
Array (
[0] => Array ( [database] => Slave 1 [dbGroup] => 1 [IO] => Yes [SQL] => Yes [Seconds] => 0 [Last_Error] => )
[1] => Array ( [database] => Slave 2 [dbGroup] => 1 [IO] => Yes [SQL] => Yes [Seconds] => 0 [Last_Error] => ) )
//Group ID 2
Array (
[2] => Array ( [database] => A Slave [dbGroup] => 2 [IO] => Yes [SQL] => Yes [Seconds] => 0 [Last_Error] => )
[3] => Array ( [database] => O Slave [dbGroup] => 2 [IO] => Yes [SQL] => Yes [Seconds] => 0 [Last_Error] => ) )
)