按特定顺序将多行字符串转换为数组

时间:2016-05-26 00:33:29

标签: php

我有一个字符串输出,我想按特定顺序转换为数组。我知道我需要它看起来像什么但不确定如何组织阵列以满足我的需要。

这是字符串输出 - 注意:可能会有更多或更少的条目" 签名证书时间戳:" - 在这个例子中有3个。我还在\n中手动添加,以显示换行符所在的位置,当作为值转换为数组时,所有换行符都是一行。

Signed Certificate Timestamp:
    Version   : v1(0)
    Log ID    : A4:B9:09:90:B4:18:58:14:87:BB:13:A2:CC:67:70:0A:\n
                3C:35:98:04:F9:1B:DF:B8:E3:77:CD:0E:C8:0D:DC:10\n
    Timestamp : Jan 30 17:05:01.387 2015 GMT
    Extensions: none
    Signature : ecdsa-with-SHA256
                30:45:02:21:00:DE:07:C0:BC:5D:A8:96:93:73:EF:30:\n
                A2:4B:2F:8F:9C:D1:EB:DD:3B:05:23:B9:04:53:1A:16:\n
                64:CE:B8:EC:D8:02:20:66:AA:0C:E5:13:FE:99:E9:A9:\n
                D9:45:9D:C1:88:4C:B4:2C:47:78:87:55:95:2D:3D:1D:\n
                14:1D:2A:E2:F9:26:2C
Signed Certificate Timestamp:
    Version   : v1(0)
    Log ID    : 56:14:06:9A:2F:D7:C2:EC:D3:F5:E1:BD:44:B2:3E:C7:\n
                46:76:B9:BC:99:11:5C:C0:EF:94:98:55:D6:89:D0:DD\n
    Timestamp : Jan 30 17:05:02.013 2015 GMT
    Extensions: none
    Signature : ecdsa-with-SHA256
                30:45:02:20:2D:0C:CD:C7:13:BD:1D:1C:F1:F5:3E:B3:\n
                E3:B6:8D:8D:CF:DE:60:56:24:16:FF:AB:88:7C:29:E4:\n
                75:DB:D3:A1:02:21:00:C2:05:4A:88:5C:C8:69:11:FB:\n
                44:E3:C6:E1:7F:10:FD:7F:27:69:83:CD:6D:4E:E2:74:\n
                97:F3:B7:AB:4B:84:C9
Signed Certificate Timestamp:
    Version   : v1(0)
    Log ID    : 68:F6:98:F8:1F:64:82:BE:3A:8C:EE:B9:28:1D:4C:FC:\n
                71:51:5D:67:93:D4:44:D1:0A:67:AC:BB:4F:4F:FB:C4\n
    Timestamp : Jan 30 17:05:01.387 2015 GMT
    Extensions: none
    Signature : ecdsa-with-SHA256
                30:45:02:21:00:C3:EE:DF:09:0D:43:74:FC:B3:81:14:\n
                01:E5:38:9E:1E:2F:98:D2:3F:DF:EB:4E:62:71:C5:80:\n
                F6:8E:8D:9C:95:02:20:1D:EB:FA:0C:44:65:A8:6F:61:\n
                78:4C:58:97:88:19:A2:E0:47:60:B8:3A:13:6E:59:FF:\n
                F1:3D:5D:F5:B6:AB:F3

以下是我希望如何组织数组

Array (
    [0] => Array
        (
            [Version] => v1(0)
            [Log ID] => A4:B9:09:90:B4:18:58:14:87:BB:13:A2:CC:67:70:0A:3C:35:98:04:F9:1B:DF:B8:E3:77:CD:0E:C8:0D:DC:10
            [Timestamp] => Jan 30 17:05:01.387 2015 GMT
            [Extensions] => none
            [Signature] => ecdsa-with-SHA256 30:45:02:21:00:DE:07:C0:BC:5D:A8:96:93:73:EF:30:A2:4B:2F:8F:9C:D1:EB:DD:3B:05:23:B9:04:53:1A:16:64:CE:B8:EC:D8:02:20:66:AA:0C:E5:13:FE:99:E9:A9:D9:45:9D:C1:88:4C:B4:2C:47:78:87:55:95:2D:3D:1D:14:1D:2A:E2:F9:26:2C
        )
    [1] => Array
        (
            [Version] => v1(0)
            [Log ID] => 56:14:06:9A:2F:D7:C2:EC:D3:F5:E1:BD:44:B2:3E:C7:46:76:B9:BC:99:11:5C:C0:EF:94:98:55:D6:89:D0:DD
            [Timestamp] => Jan 30 17:05:02.013 2015 GMT
            [Extensions] => none
            [Signature] => ecdsa-with-SHA256 30:45:02:20:2D:0C:CD:C7:13:BD:1D:1C:F1:F5:3E:B3:E3:B6:8D:8D:CF:DE:60:56:24:16:FF:AB:88:7C:29:E4:75:DB:D3:A1:02:21:00:C2:05:4A:88:5C:C8:69:11:FB:44:E3:C6:E1:7F:10:FD:7F:27:69:83:CD:6D:4E:E2:74:97:F3:B7:AB:4B:84:C9
        )
    [2] => Array
        (
            [Version] => v1(0)
            [Log ID] => 68:F6:98:F8:1F:64:82:BE:3A:8C:EE:B9:28:1D:4C:FC:71:51:5D:67:93:D4:44:D1:0A:67:AC:BB:4F:4F:FB:C4
            [Timestamp] => Jan 30 17:05:01.387 2015 GMT
            [Extensions] => none
            [Signature] => ecdsa-with-SHA256 30:45:02:21:00:C3:EE:DF:09:0D:43:74:FC:B3:81:14:01:E5:38:9E:1E:2F:98:D2:3F:DF:EB:4E:62:71:C5:80:F6:8E:8D:9C:95:02:20:1D:EB:FA:0C:44:65:A8:6F:61:78:4C:58:97:88:19:A2:E0:47:60:B8:3A:13:6E:59:FF:F1:3D:5D:F5:B6:AB:F3
        )
)

0 个答案:

没有答案