0

I have the following array, since i converted the string i got back from a SOAP call to an array:

Array
(
    [soapenvBody] => Array
        (
            [queryRequestsResponse] => Array
                (
                    [result] => Array
                        (
                            [0] => Array
                                (
                                    [BCRcustomId] => REQ16569
                                    [BCRexternalId] => Array
                                        (
                                        )

                                    [BCRrecordId] => a035700001CM60kAAD
                                    [BCRrequestId] => a1J5700000857EYEAY
                                )

                            [1] => Array
                                (
                                    [BCRcustomId] => SRQ100784
                                    [BCRexternalId] => Array
                                        (
                                        )

                                    [BCRrecordId] => a033E000001PxfAQAS
                                    [BCRrequestId] => a1J3E0000000GSaUAM
                                )

                        )

                )

        )

)

I am trying to retrieve the BCRrecordId, since I need that item to make another SOAP call. I tried the following

function getID($array) {
    return $array['BCRcustomId'];
}   

//

$arr = array_map('getID', $array );
print_r($arr);

Now i get an error back on this saying it doesnt find it.

Undefined index: BCRcustomId in index.php on line 97
[soapenvBody] => )Array (

My assumption is that it doenst go lower than 1 level in the array. Now i am not familair with these kinds of arrays, how would I solve this? By multiple for each loops? Or is there another way to retrieve these items

0

1 Answer 1

3

If $array is the whole response, you need to pass only result part of it:

$arr = array_map('getID', $array['soapenvBody']['queryRequestsResponse']['result']);
Sign up to request clarification or add additional context in comments.

1 Comment

Awesome, exactly what I needed. I didnt know I could sort out deeper in the array map. Thanks! Accept this as awnser when I can in 3 minutes

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.