Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Convert from Json to Key => Value masive
- $books = json_decode(file_get_contents("https://www.googleapis.com/books/v1/volumes?q=isbn%3A0716604892"), true);
- //initialize masive
- $myData = array();
- // get all books and added it to your masive
- foreach ($books["items"] as $book) {
- array_push($myData, $book["volumeInfo"]);
- }
- //This should be in your view page
- foreach ($myData as $value) {
- echo "<h1>". $value["title"] . "</h1>";
- echo "<div>Authors: ";
- for ($i=0; $i < count($value["authors"]); $i++) {
- echo $value["authors"][$i] ." ";
- }
- echo "</div>";
- // Check if current book have image links
- if (isset($value["imageLinks"])) {
- echo "<br> <strong>Image links</strong>: <br>";
- foreach ($value["imageLinks"] as $key => $link) {
- echo $key ." => ". $link . "<br>";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement