Home >Backend Development >PHP Tutorial >怎么处理null值成“”双引号,求大神

怎么处理null值成“”双引号,求大神

WBOY
WBOYOriginal
2016-06-20 12:39:431293browse

{
    "returnCode": "0",
    "returnDesc": "Success",
    "returnData": {
        "list": [         
            {
                "pkid": "1",
                "link_url": "",
                "banner_path": "http://test.comn/Public/upload/headpic/adver/2015-12-03/565ff9b7350e6.jpg",
                "model_type": null,
                "model_id": null
            }
        ]
    }
}


回复讨论(解决方案)

null 是怎么来的?

null 是怎么来的?

数据库字段默认是NULL

null 是怎么来的?


我试过
foreach($list as $key=>$value){
   foreach($value as $ke=>$val){
     if(empty($value[$ke]) || is_null($value[$ke])){
     $value[$ke] = "";
}
  }
}

还是不行


写APP接口蛋疼的事情多着呢  可以在json_encode那边写判断 不然改原来的model不是坑自己么。。

你只在副本上修改,当然不行

$list[$key][$ke] = "";

用全等于呢,三个等号那个。  

if($a === null){    $a = '';)

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn