I would like to have a function that would return the best a multidimension array of Associative arrays. I separated the whole output in three sections to make it read better.
What is the best way to parse such text? Where the output would be like
$output = array
(
"18"=>array(
"type"=>"backup",
"name"=>"PLC",
"Description"=>"offline db",
"state"=>"Executing",
"Start Time"=>"05/16/2012 10:55:45.240272"
),
"17"=>array(
"type"=>"restore",
"name"=>"TYNDALE",
"Description"=>"db",
"state"=>"Executing",
"Start Time"=>"05/16/2012 10:49:53.340805"
),
"15"=>array(
"type"=>"restore",
"name"=>"carinya",
"Description"=>"automatic incremental db",
"state"=>"Executing",
"Start Time"=>"05/16/2012 10:48:21.423945"
)
);
Section One + Two + Three are returned from linux command db2 list utilities show detail. So it would be an array of lines in php.
Section One
ID = 18
Type = BACKUP
Database Name = PLC
Partition Number = 0
Description = offline db
Start Time = 05/16/2012 10:55:45.240272
State = Executing
Invocation Type = User
Throttling:
Priority = Unthrottled
Progress Monitoring:
Estimated Percentage Complete = 0
Total Work = 3320093100 bytes
Completed Work = 255380 bytes
Start Time = 05/16/2012 10:55:45.240303
Section two
ID = 17
Type = RESTORE
Database Name = TYNDALE
Partition Number = 0
Description = db
Start Time = 05/16/2012 10:49:53.340805
State = Executing
Invocation Type = User
Progress Monitoring:
Completed Work = 117444608 bytes
Start Time = 05/16/2012 10:49:53.340819
Section Three
ID = 15
Type = RESTORE
Database Name = CARINYA
Partition Number = 0
Description = automatic incremental db
Start Time = 05/16/2012 10:48:21.423945
State = Executing
Invocation Type = User
Progress Monitoring:
Phase Number = 1
Total Work = 16781312 bytes
Completed Work = 16781312 bytes
Start Time = 05/16/2012 10:48:21.423954
Phase Number [Current] = 2
Description = 20120513023104
Completed Work = 272633856 bytes
Start Time = 05/16/2012 10:48:23.502822
Phase Number = 3
Description = 20120514021520
Completed Work = 0 bytes
Start Time = Not Started
So the code I use is