【发布时间】:2012-01-24 08:12:57
【问题描述】:
一个 JSON 字符串通过 HTTP 请求发送到我的网络服务,它看起来像这样:
[\"Mairie\",\"Préfectures et sous-préfectures\"]
我该如何做一个简单的php array,我可以在其中执行php arrays functions,例如implode。
我试过了,但它没有将 JSON 字符串转换为数组:
$list=json_decode($_POST["The_JSON_Parameter"],true);
编辑:
var_dump(json_decode($_POST["The_JSON_Parameter"], true));
$var=json_decode($_POST["The_JSON_Parameter"],true);
$in_list = "'".implode("','", $var)."'";
$myFile = "testFile.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, $in_list);//in the text file i got this empty string: ''
【问题讨论】:
-
pastebin.com/6dbHBxGU 好吧,也许我特别幸运? :)