我想要一个函数来返回最好的关联数组的多维数组。我将整个输出分成三个部分,以使其更好地阅读。
解析此类文本的最佳方法是什么?输出会是什么样的
$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"
)
);
第 1 + 2 + 3 节是从 linux 命令返回的db2 list utilities show detail
。所以这将是 php.ini 中的一组行。
第一节
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
第二节
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
第三节
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