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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:49:39+00:00 2026-06-07T17:49:39+00:00

I’m taking some json, made by OpenLibrary.org, and remake a new array from the

  • 0

I’m taking some json, made by OpenLibrary.org, and remake a new array from the info.
Link to the OpenLibrary json

here is my PHP code to decode the json:

$barcode = "9781599953540";

function parseInfo($barcode) {
    $url = "http://openlibrary.org/api/books?bibkeys=ISBN:" . $barcode . "&jscmd=data&format=json";
    $contents = file_get_contents($url); 
    $json = json_decode($contents, true);
    return $json;
}

the new array I’m trying to make looks something like this:

$newJsonArray = array($barcode, $isbn13, $isbn10, $openLibrary, $title, $subTitle, $publishData, $pagination, $author0, $author1, $author2, $author3, $imageLarge, $imageMedium, $imageSmall);

but when I try to get the ISBN_13 to save it to $isbn13, I get an error:

Notice: Undefined offset: 0 in ... on line 38 
// Line 38
$isbn13 = $array[0]['identifiers']['isbn_13'];

And even if I try $array[1] ,[2], [3]…. I get the same thing. What am I doning wrong here! O I know my Valuable names might not be the same, that’s because they are in different functions.

Thanks for your help.

  • 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-06-07T17:49:40+00:00Added an answer on June 7, 2026 at 5:49 pm

    Your array is not indexed by integers, it is indexed by ISBN numbers:

    Array
    (
        // This is the first level of array key!
        [ISBN:9781599953540] => Array
            (
                [publishers] => Array
                    (
                        [0] => Array
                            (
                                [name] => Center Street
                            )
    
                    )
    
                [pagination] => 376 p.
                [subtitle] => the books of mortals
                [title] => Forbidden
                [url] => http://openlibrary.org/books/OL24997280M/Forbidden
                [identifiers] => Array
                (
                    [isbn_13] => Array
                        (
                            [0] => 9781599953540
                        )
    
                    [openlibrary] => Array
                        (
                            [0] => OL24997280M
                        )
    

    So, you need to call it by the first ISBN, and the key isbn_13 is itself an array which you must access by element:

    // Gets the first isbn_13 for this item:
    $isbn13 = $array['ISBN:9781599953540']['identifiers']['isbn_13'][0];
    

    Or if you need a loop over many of them:

    foreach ($array as $isbn => $values) {
      $current_isbn13 = $values['identifiers']['isbn_13'][0];
    }
    

    If you expect only one each time and must be able to get its key without knowing it ahead of time but don’t want a loop, you can use array_keys():

    // Get all ISBN keys:
    $isbn_keys = array_keys($array);
    // Pull the first one:
    $your_item = $isbn_keys[0];
    // And use it as your index to $array
    $isbn13 = $array[$your_item]['identifiers']['isbn_13'][0];
    

    If you have PHP 5.4, you can skip a step via array dereferencing!:

    // PHP >= 5.4 only
    $your_item = array_keys($array)[0];
    $isbn13 = $array[$your_item]['identifiers']['isbn_13'][0];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

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
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have just tried to save a simple *.rtf file with some websites and
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
this is what i have right now Drawing an RSS feed into the php,
I want use html5's new tag to play a wav file (currently only supported
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.