我需要用php发送这个变量

我需要用php发送这个变量,php,json,web-services,Php,Json,Web Services,我需要创建一个函数,它接收一个变量并将其作为json发送。我期望的json输出是: { "item": [ { "a": "string", "b": "string", "c": 0 }], "country": 0 } <pre> array(2) { ['item'] => array(1) { ['sn'] => string(13) '9597/08639650

我需要创建一个函数,它接收一个变量并将其作为json发送。我期望的json输出是:

{   "item": [
    {
        "a": "string",
        "b": "string",
        "c": 0
    }],
    "country": 0
}
<pre>
array(2) {
    ['item'] => array(1) {
        ['sn'] => string(13) '9597/08639650'
    }
    ['country'] => int(717808)
}
</pre>
string(52) "{"item":{"a":"12345","b":"98765","c":0},"country":1}"
这是我在php中的函数:

$postData['item'] = 
array(
    'a' => "12345",
    'b' => "98765",
    'c' =>  0000,
);
$postData['country']= 1;
这就产生了:


阵列(2){
['item']=>数组(1){
['sn']=>字符串(13)'9597/08639650'
}
['country']=>int(717808)
}
我还得到了一个错误,它表明:
[“项不是数组类型”]

我做错了什么


关于

没有更多信息,我无法复制您的问题。这是一个与您的代码。它显示无问题的预期结果:

如果无法实现此功能,请发布更多信息,说明在实例化
$postData
和打印时发生的情况

string(52) "{"item":{"a":"12345","b":"98765","c":0},"country":1}"