代码无效
$data['price']='£1';
print_r(json_encode($data));
结果是
{"price":"null"}
我需要像
这样的结果{"price":"£1"}
答案 0 :(得分:3)
试试这个:
$data['price']='£1';
print_r(json_encode($data));
答案 1 :(得分:0)
您没有编码相同的数组..您在$ dat中存储值并编码$ data ....
检查您的代码..
答案 2 :(得分:0)
不幸的是,你恐怕无法对JSON进行编码。
你可以在它的位置试试£
,它会起作用。
答案 3 :(得分:0)
试试这个
$data['price'] = htmlentities('£1', ENT_COMPAT, 'utf-8');
答案 4 :(得分:-2)
试试这样:
$data['price']="$1";
print_r(json_encode($data));
我的结果:
{"price":"$1"}