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 4557848
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:33:59+00:00 2026-05-21T17:33:59+00:00

This is a bit of a noob question. I’m working with a JSON file

  • 0

This is a bit of a noob question. I’m working with a JSON file which looks something like this:

{"nodes": 
  [{"node": 
     {"Vocabulary name":"Bestseller Format",
      "Term":"Hardcover Fiction",
      "Bestseller1":"9780470227800",
      "Bestseller2":"9781451617962",
      "Bestseller3":"9781439167397",
      "Bestseller4":"9781617750106",
      "Bestseller5":"9780385533300",
      "Bestseller6":"9780670022526",
      "Bestseller7":"9781609530358",
      "Bestseller8":"9780132358040",
      "Bestseller9":"9780596159771",
      "Bestseller10":"9780151014163",
      "Bestseller11":"9780393334807",
      "Bestseller12":"9780805090161"}
  }]
}

And I am trying to parse it in php. I have come up with a script

<?php       
  $jsonurl = "http://www.xtracrunchy.com/pandpnewlook/?q=pandp/bestsellers";
  $json = file_get_contents($jsonurl,NULL, NULL, 0, 1000);
  $json_output = json_decode($json,true);

  $bestseller_array = $json_output[nodes][0][node];

  foreach ($bestseller_array as $key => $value)
  {
     print $key;
     print " - ";
     print $value;
     print "<br />";
   }

?>

I would like to be able to eventually build an ordered list of Bestseller ISBN’s but the only output I get when I run this script is

Vocabulary name – Bestseller Format
Term – Hardcover Fiction

and when I add print count($bestseller_array); I only get 2 elements in the array.

Any help would be appreciated.

  • 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-21T17:33:59+00:00Added an answer on May 21, 2026 at 5:33 pm

    First of, I strongly advise you make use of CURL instead of file_get_contents(), because in some occasions, it won’t work. But since it’s not a part of the question, I won’t talk about this any further.

    Secondly, you’re making use of unnamed literal constants, which is very bad.

    $json_output[nodes][0][node];
    

    Should be:

    $json_output['nodes'][0]['node'];
    

    See the documentation here on why.

    Finally, the JSON string you wrote above doesn’t match with what is returned on that url, and the script does work as expected on this “new” json.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok this may seem like a bit of a noob question but one many
i think this is a bit of a noob question, but here goes. I
I'm sorry if this is a bit of a C-noob question: I know I
Apologies for this question but I am a bit of a noob with Delphi.
This is a bit of noob question - I'm still fairly new to C#
This is a bit of a noob question but what do I need to
Pardon me if this is a noob question, I'm overextending myself a bit with
Sorry if this is a noob question, I searched quite a bit and couldn't
I guess this is a bit of a noob question but I haven't seen
This is definitely a bit of a noob question, but my searches so afar

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.