Navigate specific value in PHP Array

Asked

Viewed 89 times

2

I have a connection via api with a third party system, I am receiving the values in this format:

Array ( [code] => 200 [data] => Array ( [subscription_id] => 2752 [status] => new [custom_id] => [charges] => Array ( [0] => Array ( [charge_id] => 97652 [status] => new [total] => 1990 [parcel] => 1 ) ) [created_at] => 2016-08-29 20:17:12 ) )

What I need is to take the value of charge_id, I think it’s simple, but I haven’t found the exact way to find him.

  • Try echo $data['data']['charges'][0]['charge_id']

1 answer

2


I believe you can use a foreach this way:

foreach($data['data']['carges'] as $key => $value)
{
    echo $value['charge_id'];
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.