Jump to content

Getting values from array & stdClass Object


AndyGB

Recommended Posts

Hi

 

I am converting a JSON object into an array and displaying like so:

$json = json_decode($json);
print_r($json);

The results of which are:

stdClass Object ( [orders] => Array ( [0] => stdClass Object ( [id] => 1429118021 [email] => test@mailinator.com [closed_at] => [created_at] => 2015-10-06T18:31:45+01:00 [updated_at] => 2015-10-06T18:31:45+01:00 [number] => 2 [note] => [token] => 6c92c7c6a6fd812eb9dfc4c8b2e2517b [gateway] => Bank Deposit [test] => [total_price] => 39.94 [subtotal_price] => 31.94 [total_weight] => 357 [total_tax] => 5.32 [taxes_included] => 1 [currency] => GBP [financial_status] => pending [confirmed] => 1 [total_discounts] => 0.00 [total_line_items_price] => 31.94 [cart_token] => db1e1fc102f3a3ae565feebf5793bfdc [buyer_accepts_marketing] => [name] => #1002 [referring_site] => http://sebi024.myshopify.com/ [landing_site] => /collections/all [cancelled_at] => [cancel_reason] => [total_price_usd] => 60.52 [checkout_token] => 06a996b75a8cb03819096c93cd2a2d63 [reference] =>

What I am basically trying to do is get the values, such as the ID number, which I was hoping to do like this:

$json['orders'][0]['id']

Clearly that was too easy :/

 

I am guessing I can't do that because these are objects within arrays within objects?

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.