我如何从json对象获取此变量?

时间:2016-03-09 13:35:22

标签: php json ajax

我有一个页面(insert.php),我试图将包含$ my_variable的响应作为json数组返回到另一个页面(form.php)。

我可以在我的firebug控制台的响应部分看到这个数组,但我怎样才能在form.php上找到它并与php一起使用?

insert.php正在发送:

// sending output
header('Content-Type: text/json');
echo json_encode(array("my_var" => "$my_variable"));
}

1 个答案:

答案 0 :(得分:0)

只需使用json_decode函数

$arr = json_decode($_REQUEST['my_var'],true);