匹配数组元素

时间:2015-03-04 12:15:36

标签: php arrays

源数组$文件夹(项目)

[30] => stdClass Object
    (
        [FolderId] => stdClass Object
            (
                [Id] => AAMkADY5ZTA5NDE5LTFiYzYtNGNkZi04YjU4LWNjM2Y2MTE3OGQ0YgAuAAAAAABGFlXY0ZfcTZ2wwDCnMUklAQBdhw2ay71OSIMPgC3vw99AAAA5dpB6AAA=
                [ChangeKey] => AQAAABYAAABXAiaO6I1mSLPb3pxjHQltAAIN0dfI
            )

        [ParentFolderId] => stdClass Object
            (
                [Id] => AAMkADY5ZTA5NDE5LTFiYzYtNGNkZi04YjU4LWNjM2Y2MTE3OGQ0YgAuAAAAAABGFlXY0ZfcTZ2wwDCnMUklAQBdhw2ay71OSIMPgC3vw99AAAA5dpAeAAA=
                [ChangeKey] => AQAAAA==
            )

        [FolderClass] => IPF.Note
        [DisplayName] => Copaco
        [TotalCount] => 42
        [ChildFolderCount] => 1
        [EffectiveRights] => stdClass Object
            (
                [CreateAssociated] => 1
                [CreateContents] => 1
                [CreateHierarchy] => 1
                [Delete] => 1
                [Modify] => 1
                [Read] => 1
            )

        [UnreadCount] => 0
    )

[31] => stdClass Object
    (
        [FolderId] => stdClass Object
            (
                [Id] => AAMkADY5ZTA5NDE5LTFiYzYtNGNkZi04YjU4LWNjM2Y2MTE3OGQ0YgAuAAAAAABGFlXY0ZfcTZ2wwDCnMUklAQBdhw2ay71OSIMPgC3vw99AAAA5dpFKAAA=
                [ChangeKey] => AQAAABQAAADvdpLCY3TtQbRXZwMA0E6qAA0oNQ==
            )

        [ParentFolderId] => stdClass Object
            (
                [Id] => AAMkADY5ZTA5NDE5LTFiYzYtNGNkZi04YjU4LWNjM2Y2MTE3OGQ0YgAuAAAAAABGFlXY0ZfcTZ2wwDCnMUklAQBdhw2ay71OSIMPgC3vw99AAAA5dpB6AAA=
                [ChangeKey] => AQAAAA==
            )

        [FolderClass] => IPF.Note
        DisplayName] => Orderbevestigingen
        [TotalCount] => 1
        [ChildFolderCount] => 0
        [EffectiveRights] => stdClass Object
            (
                [CreateAssociated] => 1
                [CreateContents] => 1
                [CreateHierarchy] => 1
                [Delete] => 1
                [Modify] => 1
                [Read] => 1
            )

        [UnreadCount] => 0
    )

使用此代码

从中构建数组
if($response->ResponseMessages->FindFolderResponseMessage->RootFolder->TotalItemsInView > 0){

    $folders                                                            = $response->ResponseMessages->FindFolderResponseMessage->RootFolder->Folders->Folder;

    foreach($folders as $folder){
        $calname                                                    = $folder->DisplayName;
        $id                                                         = $folder->FolderId->Id;
        $ChangeKey                                                  = $folder->FolderId->ChangeKey;
        $parentid                                                   = $folder->ParentFolderId->Id;
        $parentchangekey                                            = $folder->ParentFolderId->ChangeKey;

        $foldersExchange[$id]['name']                               = $calname;
        $foldersExchange[$id]['folderid']                           = $id;
        $foldersExchange[$id]['changekey']                          = $ChangeKey;
        $foldersExchange[$id]['parentid']                           = $parentid;
        $foldersExchange[$id]['parentchangekey']                    = $parentchangekey;
    }
}

$ foldersExchange的结果

[AAMkADY5ZTA5NDE5LTFiYzYtNGNkZi04YjU4LWNjM2Y2MTE3OGQ0YgAuAAAAAABGFlXY0ZfcTZ2wwDCnMUklAQBdhw2ay71OSIMPgC3vw99AAAA5dpB6AAA=] => Array
    (
        [name] => Copaco
//      [folderid] => AAMkADY5ZTA5NDE5LTFiYzYtNGNkZi04YjU4LWNjM2Y2MTE3OGQ0YgAuAAAAAABGFlXY0ZfcTZ2wwDCnMUklAQBdhw2ay71OSIMPgC3vw99AAAA5dpB6AAA=
        [changekey] => AQAAABYAAABXAiaO6I1mSLPb3pxjHQltAAIN0dfI
        [parentid] => AAMkADY5ZTA5NDE5LTFiYzYtNGNkZi04YjU4LWNjM2Y2MTE3OGQ0YgAuAAAAAABGFlXY0ZfcTZ2wwDCnMUklAQBdhw2ay71OSIMPgC3vw99AAAA5dpAeAAA=
        [parentchangekey] => AQAAAA==
    )

[AAMkADY5ZTA5NDE5LTFiYzYtNGNkZi04YjU4LWNjM2Y2MTE3OGQ0YgAuAAAAAABGFlXY0ZfcTZ2wwDCnMUklAQBdhw2ay71OSIMPgC3vw99AAAA5dpFKAAA=] => Array
    (
        [name] => Orderbevestigingen
        [folderid] => AAMkADY5ZTA5NDE5LTFiYzYtNGNkZi04YjU4LWNjM2Y2MTE3OGQ0YgAuAAAAAABGFlXY0ZfcTZ2wwDCnMUklAQBdhw2ay71OSIMPgC3vw99AAAA5dpFKAAA=
        [changekey] => AQAAABQAAADvdpLCY3TtQbRXZwMA0E6qAA0oNQ==
//      [parentid] => AAMkADY5ZTA5NDE5LTFiYzYtNGNkZi04YjU4LWNjM2Y2MTE3OGQ0YgAuAAAAAABGFlXY0ZfcTZ2wwDCnMUklAQBdhw2ay71OSIMPgC3vw99AAAA5dpB6AAA=
        [parentchangekey] => AQAAAA==
    )

结果我正在寻找

[AAMkADY5ZTA5NDE5LTFiYzYtNGNkZi04YjU4LWNjM2Y2MTE3OGQ0YgAuAAAAAABGFlXY0ZfcTZ2wwDCnMUklAQBdhw2ay71OSIMPgC3vw99AAAA5dpB6AAA=] => Array
    (
    [name] => Copaco
        [folderid] => AAMkADY5ZTA5NDE5LTFiYzYtNGNkZi04YjU4LWNjM2Y2MTE3OGQ0YgAuAAAAAABGFlXY0ZfcTZ2wwDCnMUklAQBdhw2ay71OSIMPgC3vw99AAAA5dpB6AAA=
        [changekey] => AQAAABYAAABXAiaO6I1mSLPb3pxjHQltAAIN0dfI
        [parentid] => AAMkADY5ZTA5NDE5LTFiYzYtNGNkZi04YjU4LWNjM2Y2MTE3OGQ0YgAuAAAAAABGFlXY0ZfcTZ2wwDCnMUklAQBdhw2ay71OSIMPgC3vw99AAAA5dpAeAAA=
        [parentchangekey] => AQAAAA==
    [children] => Array
                (
                    [name] => Orderbevestigingen
            [folderid] => AAMkADY5ZTA5NDE5LTFiYzYtNGNkZi04YjU4LWNjM2Y2MTE3OGQ0YgAuAAAAAABGFlXY0ZfcTZ2wwDCnMUklAQBdhw2ay71OSIMPgC3vw99AAAA5dpFKAAA=
            [changekey] => AQAAABQAAADvdpLCY3TtQbRXZwMA0E6qAA0oNQ==
            [parentid] => AAMkADY5ZTA5NDE5LTFiYzYtNGNkZi04YjU4LWNjM2Y2MTE3OGQ0YgAuAAAAAABGFlXY0ZfcTZ2wwDCnMUklAQBdhw2ay71OSIMPgC3vw99AAAA5dpB6AAA=
            [parentchangekey] => AQAAAA==
                )
    )

我不知道怎么做,因为我构建的数组的关键元素不同,所以我没有共同的标识符。

您对如何实现此结果有任何提示吗?

0 个答案:

没有答案