Parse WordPress JSON with PHP

For me as a PHP beginner the JSON structure stored by WordPress in the mySql database is quite complex. But I would like to get certain information out of a complex JSON structure. Could you please help to get the data out of this JSON string in a human friendly structure by using PHP?

I want to get the filenames near the “file” elements:

Read More
a: 5: {
s: 5: "width";i: 428;s: 6: "height";i: 324;s: 4: "file";s: 15: "Clipboard12.jpg";s: 5: "sizes";a: 9: {
    s: 9: "thumbnail";a: 4: {
        s: 4: "file";s: 23: "Clipboard12-150x150.jpg";s: 5: "width";i: 150;s: 6: "height";i: 150;s: 9: "mime-type";s: 10: "image/jpeg";
    }
    s: 6: "medium";a: 4: {
        s: 4: "file";s: 23: "Clipboard12-300x227.jpg";s: 5: "width";i: 300;s: 6: "height";i: 227;s: 9: "mime-type";s: 10: "image/jpeg";
    }
    s: 14: "post-thumbnail";a: 4: {
        s: 4: "file";s: 22: "Clipboard12-100x65.jpg";s: 5: "width";i: 100;s: 6: "height";i: 65;s: 9: "mime-type";s: 10: "image/jpeg";
    }
    s: 9: "art-thumb";a: 4: {
        s: 4: "file";s: 22: "Clipboard12-100x65.jpg";s: 5: "width";i: 100;s: 6: "height";i: 65;s: 9: "mime-type";s: 10: "image/jpeg";
    }
    s: 8: "art-wide";a: 4: {
        s: 4: "file";s: 23: "Clipboard12-326x159.jpg";s: 5: "width";i: 326;s: 6: "height";i: 159;s: 9: "mime-type";s: 10: "image/jpeg";
    }
    s: 12: "art-big-1col";a: 4: {
        s: 4: "file";s: 23: "Clipboard12-326x235.jpg";s: 5: "width";i: 326;s: 6: "height";i: 235;s: 9: "mime-type";s: 10: "image/jpeg";
    }
    s: 15: "art-slide-small";a: 4: {
        s: 4: "file";s: 23: "Clipboard12-326x324.jpg";s: 5: "width";i: 326;s: 6: "height";i: 324;s: 9: "mime-type";s: 10: "image/jpeg";
    }
    s: 7: "art-gal";a: 4: {
        s: 4: "file";s: 23: "Clipboard12-210x210.jpg";s: 5: "width";i: 210;s: 6: "height";i: 210;s: 9: "mime-type";s: 10: "image/jpeg";
    }
    s: 10: "td_198x143";a: 4: {
        s: 4: "file";s: 23: "Clipboard12-198x143.jpg";s: 5: "width";i: 198;s: 6: "height";i: 143;s: 9: "mime-type";s: 10: "image/jpeg";
    }
}
s: 10: "image_meta";a: 11: {
    s: 8: "aperture";i: 0;s: 6: "credit";s: 0: "";s: 6: "camera";s: 0: "";s: 7: "caption";s: 0: "";s: 17: "created_timestamp";i: 0;s: 9: "copyright";s: 0: "";s: 12: "focal_length";i: 0;s: 3: "iso";i: 0;s: 13: "shutter_speed";i: 0;s: 5: "title";s: 0: "";s: 11: "orientation";i: 0;
}

}

By executing the PHP file I would like to see as results:

Clipboard0340-100x65.jpg
Clipboard0340-150x150.jpg
Clipboard0340-198x143.jpg
Clipboard0340-210x210.jpg
Clipboard0340-300x209.jpg
Clipboard0340-326x159.jpg
Clipboard0340-326x235.jpg
Clipboard0340-326x406.jpg
Clipboard0340-513x357.jpg
Clipboard0340-674x357.jpg
Clipboard0340.jpg 

Related posts

Leave a Reply

2 comments

  1. Have a look at this page. You will need to use a loop (foreach or while) to loop through all the results and then store the retrieved data to an array before using echo to print it out.

    Hope that helps.