Daniel Stappenbeck
Daniel Stappenbeck

Reputation: 9

PHP: Reverse lookup in JSON by searchfind value in key, Planradar API

I currently have the challenge of performing a reverse search in PHP for a JSON. I´m looking for value "ogwoaml" in Key "user-id". Then I need to check if "id" of this Object with Keys is "bonwbono". Screenshot of JSON-Code

{
    "data": [
        {
            "id": "bonwbono",
            "type": "journals",
            "attributes": {
                "id": "bonwbono",
                "notes": "Handwerker sind am 30.11.2023...",
                "created-on": "2023-11-30T21:12:10.823Z",
                "journalized-id": "xmbmmbzl",
                "user-id": "ogwoaml"
            },
            "relationships": {
                "journal-details": {
                    "data": []
                },
                "user": {
                    "data": {
                        "id": "ogwoaml",
                        "type": "users"
                    }
                }
            }
        },
        {
            "id": "delnjepz",
            "type": "journals",
            "attributes": {
                "id": "delnjepz",
                "notes": null,
                "created-on": "2023-11-30T21:11:08.825Z",
                "journalized-id": "xmbmmbzl",
                "user-id": "ogwoaml"
            },
            "relationships": {
                "journal-details": {
                    "data": [
                        {
                            "id": "lyngjyag",
                            "type": "journal-details"
                        }
                    ]
                },
                "user": {
                    "data": {
                        "id": "ogwoaml",
                        "type": "users"
                    }
                }
            }
        }
    ]
}

I want to be honest. I have taught myself HTML, PHP, SQL JSON and have already mastered many challenges, but unfortunately I am currently missing an approach to mastering this challenge. I hope for strong impulses from the community.

Basically handling of JSON in PHP is quite clear.

$obj = json_decode($value);
$foo = $obj -> data -> 0 -> attributes-> user-id;

End of day I need to filter how many times we have id:"bonwbono" and user-id:"ogwoaml" in same Object with Keys. The snipped code is only part of in total approx 75 issues.

Upvotes: 0

Views: 23

Answers (0)

Related Questions