1

Is there a way to extract the array for a specified id with the set::class utiliy? I can't figure out the XPath.

I.E. I would like to extract the array where the id = 1

[Document] => Array
        (
            [0] => Array
                (
                    [id] => 1
                    [filename] => 1.txt
                )

            [1] => Array
                (
                    [id] => 2
                    [filename] => 2.txt
                )

            [2] => Array
                (
                    [id] => 3
                    [filename] => 3.txt
                )


        )

1 Answer 1

1

Try:

Set::extract('/[id=1]', $data['Document']);

or

Set::extract('/[id=1]/..', $data['Document']);

Sign up to request clarification or add additional context in comments.

1 Comment

In my case Set::extract('/Document[id=1]', $document) worked. Thanks again Neil

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.