怎么去掉单引号
$arr=array('as'=>1,'data'=>array('ID'=>$r_id,'List'=>$zfc));
echo json_encode($arr,JSON_FORCE_OBJECT);
{
"as": 1,
"data": {
"ID": "111",
"NeedImgList": "1.jpg,2.jpg"
}
}
怎么把ID 中"111" 的双引号去掉???
------解决思路----------------------
$r_id = 111;
$zfc = '123';
$arr=array('as'=>1,'data'=>array('ID'=>$r_id,'List'=>$zfc));
echo json_encode($arr,JSON_FORCE_OBJECT
------解决思路----------------------
JSON_PRETTY_PRINT);
{可知 "111" 的双引号是你自己造成的(字符串)
"as": 1,
"data": {
"ID": 111,
"List": "123"
}
}
这样写就没有了
$arr=array('as'=>1,'data'=>array('ID'=>intval($r_id),'List'=>$zfc));
------解决思路----------------------
因为是字符型,所以有引号,可以这样改。
$arr=array('as'=>1,'data'=>array('ID'=>intval($r_id),'List'=>$zfc));
echo json_encode($arr,JSON_FORCE_OBJECT);
------解决思路----------------------
$arr=array('as'=>1,'data'=>array('ID'=>$r_id+0,'List'=>$zfc));
echo json_encode($arr,JSON_FORCE_OBJECT);