Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7417917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:47:25+00:00 2026-05-29T07:47:25+00:00

I’m getting back a JSON string from a third party API. When I use

  • 0

I’m getting back a JSON string from a third party API. When I use json_decode($json, true) to put it into an array, I end up with a nested array. It seems to me it shouldn’t be like this. Can someone explain if this is correct behavior?

$obj = getStatus('100000043');
var_dump($obj);

getStatus calls the third-party API. The result of var_dump is:

string(245)
“[{“Status”:”Processing”,”OrderNum”:”87″,”InvoiceNum”:”0″,”PoNum”:”100000043″,”ShippingCost”:””,”TrackingNum”:””,”ShippingWeight”:””,”cust_num”:”123″,”entryTime”:”2012-02-02
15:19:05″,”branch”:”0″,”CustPoNum”:”43″,”brord”:”12345″}]”

Ok, so I decode to an array:

$myArray = json_decode($obj, true); 
var_dump($myArray);

result is:

array(1) { [0]=> array(12) {
[“Status”]=>
string(10) “Processing”
[“OrderNum”]=>
string(5) “87686”
[“InvoiceNum”]=>
string(1) “0”
[“PaPoNum”]=>
string(9) “100000043”
[“ShippingCost”]=>
string(0) “”
[“TrackingNum”]=>
string(0) “”
[“ShippingWeight”]=>
string(0) “”
[“cust_num”]=>
string(5) “64366”
[“entryTime”]=>
string(19) “2012-02-02 15:19:05”
[“branch”]=>
string(1) “8”
[“CustPoNum”]=>
string(9) “100000043”
[“brord”]=>
string(6) “887686” } }

The array I want is nested within $myArray[0] …
How to get a value out:

$myArray[0]['Status']

From the docs and examples I would expect $myArray[‘Status’] to work.

Do i misunderstand or I’m doing something wrong or is there something funky about the API result?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T07:47:25+00:00Added an answer on May 29, 2026 at 7:47 am

    with json encoded data, when you have code that starts with a square brace, then it contains data with curly braces: [{data}], it’s always going to be a nested array.

    It’s simple enough to access the data using $myArray[0]['Status'].
    You can also assign $myArray[0] to $myArray like this:

    $myArray = $myArray[0];
    

    Then you can access all elements of the array using this syntax:

    $myArray['Status'];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently running into a problem where an element is coming back from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
I am trying to understand how to use SyndicationItem to display feed which is
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.