在php中提取json数据并打印出来

时间:2014-10-03 07:39:46

标签: php json

array(2) { 
    ["data"]=> array(1) 
    { 
        ["MemberData"]=> array(1) 
        { 
            ["Verified"]=> string(1) "Y" 
        } 
    } 
    ["error"]=> array(2) 
    { 
        ["code"]=> string(0) "" 
        ["text"]=> string(0) "" 
    } 
}

/我想在php页面/

中打印验证值

1 个答案:

答案 0 :(得分:0)

这是从PHP到javascript的方法:

var ar = JSON.parse( '<?php echo json_encode($array) ?>' );
//ar[1]['MemberData'];  //first memberdata value

console.log(ar[1]['MemberData'].value);

从javascript到php你需要使用ajax

jQuery.ajax({
    type: "POST",
     url: 'xxxxxxx',
    dataType: 'json', 
    data: {array:array, //here you can pass the verified value of the array or the whole array if you want 
        },
    success: function(data) {
            if(data.success == true){ 

            }
            },
    error: function(data) {
            if(data.success != true){ 

            }
            },
        });

然后你可以像在PHP端的普通POST那样阅读它。

除此之外,将使用?verified ='javascript_array_value'重新加载网址并使用GET读取