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

  • Home
  • SEARCH
  • 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 8738529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:44:59+00:00 2026-06-13T10:44:59+00:00

Possible Duplicate: PHP JSON decode – stdClass I have a JSON file with a

  • 0

Possible Duplicate:
PHP JSON decode – stdClass

I have a JSON file with a structure like this:

[{"key_mappings": "",
  "screen2_thumb": "http://games.mochiads.com/c/g/siegius-arena/screen2_thumb.png",
  "video_url": "http://www.youtube.com/watch?v=S7MDxObgJxw",
  "rating": "Teen",
  "screen1_thumb": "http://games.mochiads.com/c/g/siegius-arena/screen1_thumb.png",
  "metascore": 43.63,
  "height": 500,
  "screen3_thumb": "http://games.mochiads.com/c/g/siegius-arena/screen3_thumb.jpg",
  "stage3d": false,
  "screen3_url": "http://games.mochiads.com/c/g/siegius-arena/screen3.jpg", 
  "recommendation": 5,
  "coins_revshare_enabled": null,
  "category": "Fighting",
  "screen4_thumb": "http://games.mochiads.com/c/g/siegius-arena/screen4_thumb.png",
  "uuid": "6789c7e3-fd27-345e-85d9-e6a58165ae57",
  "author": "Juice-Tin",
  "thumbnail_large_url": "http://games.mochiads.com/c/g/siegius-arena/_thumb_200x200.png",
  "author_link": "https://www.mochimedia.com/community/profile/Juice-Tin",
  "controls":
    [["C", "Item"],
     ["V", "Spell"],
     ["X", "Heavy Attack"],
     ["Z", "Fast Attack"],
     ["fire", "na"],
     ["jump", "na"],
     ["movement", "arrow"]],
  "languages": ["en"],
  "swf_url": "http://games.mochiads.com/c/g/siegius-arena/Siegius%20Arena_.swf",
  "recommended": true,
  "game_tag": "e0e05c5c5fd1a61b",
  "achievements_enabled": false,
  "zip_url": "http://games.mochiads.com/c/g/siegius-arena.zip",
  "screen1_url": "http://games.mochiads.com/c/g/siegius-arena/screen1.png",
  "updated": "2012-10-25T15:47:01.953336-08:00",
  "description": "Fight in arena battles and upgrade your gladiator in this Action-RPG about betrayal and revenge.",
  "tags": ["siegius", "arena", "gladiator", "rome", "battle", "fight", "upgrade", "rpg", "fans", "en"],
  "swf_file_size": 10142842,
  "leaderboard_enabled": false,
  "game_url": "http://www.mochimedia.com/games/siegius-arena",
  "screen2_url": "http://games.mochiads.com/c/g/siegius-arena/screen2.png",
  "slug": "siegius-arena",
  "categories": ["Action", "Fighting"],
  "instructions": "", 
  "name": "Siegius Arena",
  "created": "2012-10-25T12:47:55.080005-08:00",
  "control_scheme": "{\"C\": \"Item\", \"fire\": \"na\", \"jump\": \"na\", \"V\": \"Spell\", \"X\": \"Heavy Attack\", \"Z\": \"Fast Attack\", \"movement\": \"arrow\"}", 
  "popularity": 0,
  "feed_approval_created": "2012-10-25T13:30:53.505710-08:00",
  "coins_enabled": null,
  "thumbnail_url": "http://games.mochiads.com/c/g/siegius-arena/_thumb_100x100.png",
  "screen4_url": "http://games.mochiads.com/c/g/siegius-arena/screen4.png", 
  "alternate_url": "",
  "resolution": "800x500",
  "width": 800}]

Then, I have a foreach statement which adds the data to a MYSQL database:

foreach($result as $key => $value) {
    if($value) { 
    mysql_query("INSERT INTO `games_db`.`Games` (`title`, `description`, `image`, `category`, `page`, `rating`, `width`, `height`, `tags`) VALUES ('$value->name', '$value->description', '/images/$pageid.jpg', '$category', '$pageid', '$value->rating', '$value->width', '$value->height', '$value->tags')")  
}

My question is, What do I have to do to show and insert the tags from the JSON file? Currently, When I run this page, the data for the “tags” column just says “Array”.

  • 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-13T10:45:00+00:00Added an answer on June 13, 2026 at 10:45 am

    You can use json_decode() as so:

    $jsonString = '[{"key_mappings": "", "screen2_thumb": "http://games.mochiads.com/c/g/siegius-arena/screen2_thumb.png", "video_url": "http://www.youtube.com/watch?v=S7MDxObgJxw", "rating": "Teen", "screen1_thumb": "http://games.mochiads.com/c/g/siegius-arena/screen1_thumb.png", "metascore": 43.63, "height": 500, "screen3_thumb": "http://games.mochiads.com/c/g/siegius-arena/screen3_thumb.jpg", "stage3d": false, "screen3_url": "http://games.mochiads.com/c/g/siegius-arena/screen3.jpg", "recommendation": 5, "coins_revshare_enabled": null, "category": "Fighting", "screen4_thumb": "http://games.mochiads.com/c/g/siegius-arena/screen4_thumb.png", "uuid": "6789c7e3-fd27-345e-85d9-e6a58165ae57", "author": "Juice-Tin", "thumbnail_large_url": "http://games.mochiads.com/c/g/siegius-arena/_thumb_200x200.png", "author_link": "https://www.mochimedia.com/community/profile/Juice-Tin", "controls": [["C", "Item"], ["V", "Spell"], ["X", "Heavy Attack"], ["Z", "Fast Attack"], ["fire", "na"], ["jump", "na"], ["movement", "arrow"]], "languages": ["en"], "swf_url": "http://games.mochiads.com/c/g/siegius-arena/Siegius%20Arena_.swf", "recommended": true, "game_tag": "e0e05c5c5fd1a61b", "achievements_enabled": false, "zip_url": "http://games.mochiads.com/c/g/siegius-arena.zip", "screen1_url": "http://games.mochiads.com/c/g/siegius-arena/screen1.png", "updated": "2012-10-25T15:47:01.953336-08:00", "description": "Fight in arena battles and upgrade your gladiator in this Action-RPG about betrayal and revenge.", "tags": ["siegius", "arena", "gladiator", "rome", "battle", "fight", "upgrade", "rpg", "fans", "en"], "swf_file_size": 10142842, "leaderboard_enabled": false, "game_url": "http://www.mochimedia.com/games/siegius-arena", "screen2_url": "http://games.mochiads.com/c/g/siegius-arena/screen2.png", "slug": "siegius-arena", "categories": ["Action", "Fighting"], "instructions": "", "name": "Siegius Arena", "created": "2012-10-25T12:47:55.080005-08:00", "control_scheme": "{\"C\": \"Item\", \"fire\": \"na\", \"jump\": \"na\", \"V\": \"Spell\", \"X\": \"Heavy Attack\", \"Z\": \"Fast Attack\", \"movement\": \"arrow\"}", "popularity": 0, "feed_approval_created": "2012-10-25T13:30:53.505710-08:00", "coins_enabled": null, "thumbnail_url": "http://games.mochiads.com/c/g/siegius-arena/_thumb_100x100.png", "screen4_url": "http://games.mochiads.com/c/g/siegius-arena/screen4.png", "alternate_url": "", "resolution": "800x500", "width": 800}]';
    $jsonObject = json_decode($jsonString);
    foreach ($jsonObject->tags as $tag) {
        echo $tag . PHP_EOL;
        //Do something
    }
    

    If you use less than PHP 5.2.0, you can use the JSON PECL Extension

    I should also add that you shouldn’t use the mysql functions any more – they’re deprecated. See: Why shouldn't I use mysql_* functions in PHP?

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

Sidebar

Related Questions

Possible Duplicate: PHP : Create array for JSON I have an array like this
Possible Duplicate: How to decode a JSON string in PHP? I would like to
Possible Duplicate: Forcing to download a file using PHP If I have a json
Possible Duplicate: php loop through associative arrays i have this piece of code which
Possible Duplicate: Parse Json in php I was looking for this awnser but couldnt
Possible Duplicate: JSON Parsing with PHP I'm hoping for a little assistance on this.
Possible Duplicate: PHP - send file to user I have written a script that
Possible Duplicate: Can't decode JSON string in php I'm at my wits end here,
Possible Duplicate: PHP global in functions Using something like this worries me: <? global
Possible Duplicate: How can I decode json in PHP 5.1? I am using json_encode

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.