I’m very new to php and I have a Json like this :
{
"customer_id": "guest_user_101",
"merchantId": "guest",
"cards":
[
{
"card_token": "0784ba0c-dc07-489e-a57d-16dfcb39868f"
},
{
"card_token": "fe4ebe01-bbb6-46b6-8e49-5c572ee20bc7"
}
]
}
I wish to find whether there is a card_token in cards. Are there any easy and elegant way to do that? Note that there can also be a case where cards have empty list.
Currently I do this way:
$json->cards[0]->card_token
But I guess there will be a better solution for this problem.
Thanks in advance.
Should work 🙂 Might need a bit of tweaking because I can’t test it at the moment but the concept is there.