我如何将字符串解码为json?

时间:2019-07-25 13:31:06

标签: php json wordpress

我有一个数组。其中的字符串需要转换为JSON数组,然后访问它们并显示数据。我每次都显示NULL http://prntscr.com/ojx5jv

    $array =  get_user_meta(  $cur_user_id, 'json' );
    var_dump($array);

     foreach ($array as $key => $value) {
        echo "<dt>$key:</dt>";
        echo "<dd>$value</dd>";
        $arr = (json_decode(($value), true));
        var_dump($arr);

     }

我已经问过这样的问题。我错了

第一个转储行2

array (size=4)
  0 => string '"{"cards1":["Mu0100Cu012au0160ANu0100S PRASMES","IZGLu012aTOT",null],"cards2":["Mu0100Cu012au0160ANu0100S PRASMES","IZVEIDOT",null],"cards3":["Mu0100Cu012au0160ANu0100S PRASMES","ATBALSTu012aT",null]}"' (length=201)
  1 => string '"{"cards1":["RADOu0160u0100S PRASMES","IZMAINu012aT",null],"cards2":["RADOu0160u0100S PRASMES","IZPILDu012aT",null],"cards3":["RADOu0160u0100S PRASMES","PLu0100NOT",null]}"' (length=172)
  2 => string '"{"cards1":["Mu0100Cu012au0160ANu0100S PRASMES","NOTEIKT",null],"cards2":["Mu0100Cu012au0160ANu0100S PRASMES","IZSKAIDROT",null],"cards3":["Mu0100Cu012au0160ANu0100S PRASMES","IZVEIDOT",null]}"' (length=193)
  3 => string '"{"cards1":["NOTEIKT",null],"cards2":["IZVEIDOT",null],"cards3":["IZSKAIDROT",null]}"' (length=85)

第二次转储

0:
"{"cards1":["Mu0100Cu012au0160ANu0100S PRASMES","IZGLu012aTOT",null],"cards2":["Mu0100Cu012au0160ANu0100S PRASMES","IZVEIDOT",null],"cards3":["Mu0100Cu012au0160ANu0100S PRASMES","ATBALSTu012aT",null]}"
C:\wamp64\www\wordpress.game\wp-content\plugins\WPgame Custom Plugin\WPcafe-custom-plugin.php:82:null
1:
"{"cards1":["RADOu0160u0100S PRASMES","IZMAINu012aT",null],"cards2":["RADOu0160u0100S PRASMES","IZPILDu012aT",null],"cards3":["RADOu0160u0100S PRASMES","PLu0100NOT",null]}"
C:\wamp64\www\wordpress.game\wp-content\plugins\WPgame Custom Plugin\WPcafe-custom-plugin.php:82:null
2:
"{"cards1":["Mu0100Cu012au0160ANu0100S PRASMES","NOTEIKT",null],"cards2":["Mu0100Cu012au0160ANu0100S PRASMES","IZSKAIDROT",null],"cards3":["Mu0100Cu012au0160ANu0100S PRASMES","IZVEIDOT",null]}"
C:\wamp64\www\wordpress.game\wp-content\plugins\WPgame Custom Plugin\WPcafe-custom-plugin.php:82:null
3:
"{"cards1":["NOTEIKT",null],"cards2":["IZVEIDOT",null],"cards3":["IZSKAIDROT",null]}"
C:\wamp64\www\wordpress.game\wp-content\plugins\WPgame Custom Plugin\WPcafe-custom-plugin.php:82:null

0 个答案:

没有答案