PHP/JSON-如何在导入mysql之前解析

PHP/JSON-如何在导入mysql之前解析,php,mysql,json,Php,Mysql,Json,我想将一些项目从json保存到数据库中 json源代码如下: 我只想保存那些值的数据库 “储罐标识”: “战斗”: “胜利”: 每节 要使用脚本的这一部分检查JSON源代码i,工作正常 function readWotResponse($url, $isUrl = true) { if ($isUrl && !ini_get('allow_url_fopen')) { throw new Exception('allow_url_fopen = Off'); }

我想将一些项目从json保存到数据库中

json源代码如下:

我只想保存那些值的数据库

“储罐标识”: “战斗”: “胜利”:

每节

要使用脚本的这一部分检查JSON源代码i,工作正常

function readWotResponse($url, $isUrl = true)
{
  if ($isUrl && !ini_get('allow_url_fopen')) {
    throw new Exception('allow_url_fopen = Off');
  }

  $content = file_get_contents($url);
  if ($isUrl) {
   $status_code = substr($http_response_header[0], 9, 3);
  if ($status_code != 200) {
      throw new Exception('Got status code ' . $status_code . ' expected 200');
    }
  }

  $json = json_decode($content);
  if (!$json) {
    throw new Exception('Response contained an invalid JSON response');
  }

  if ($json->status != 'ok') {
    throw new Exception($json->status_code);
  }

  return $json;
}
为了解析,我尝试了

$tanks_id_url = "http://api.worldoftanks.eu/2.0/account/tanks/?application_id=d0a293dc77667c9328783d489c8cef73&account_id=500014703";

    try {
         $tjson = readWotResponse($tanks_id_url);
         print_r ($tjson) ;
       } 
所以现在我需要好的解析帮助来获得好的价值

当我使用var_dump时,我得到了这个

 object(stdClass)#1 (3) {   ["status"]=>   string(2) "ok"   ["count"]=>
 int(1)   ["data"]=>   object(stdClass)#2 (1) {
     ["500014703"]=>
     array(106) {
      [0]=>
       object(stdClass)#3 (6) {
         ["achievements"]=>
         object(stdClass)#4 (59) {
           ["medal_dumitru"]=>
           int(0) . . . . .
这部分对我来说是个问题

    **array(106) {
      [0]=>**
因为当我想用的时候

$value = $tjson->data->500014703->O->achievements->medal_dumitru;

我得到了错误:-(

“获得了好的值”?嗯?当我只想将那些值“tank_id”保存到数据库时,如何解析这个JSON:“battles:“wins”:一旦通过JSON_decode()传递JSON,就有了一个本机PHP数据结构。
var_dump($tjson)
将向您展示如何获取所需内容的确切细节。在PHP数据结构中访问内容是核心/基础知识。如果您无法处理它,那么您需要退后一步,学习基本编程。我们是来帮助您的,而不是您的老师好答案:-(帮助我