Home > Backend Development > PHP Tutorial > php if条件判断数组回到[false]

php if条件判断数组回到[false]

WBOY
Release: 2016-06-13 12:24:58
Original
1006 people have browsed it

php if条件判断数组返回[false]

{"code":200,"message":"success","data":[false]}
Copy after login

 $sql_notice=mysql_query(sql语句)<br />    $arrData =array();<br />    while ($arrData[] = mysql_fetch_array($sql_notice))<br />    {<br />       $arrData;<br />    }<br />    $sData = array_values($arrData);<br />    if(。。。){<br />    Response::json(200,'success',$sData);<br />    }else{<br />    Response::json(400,'error',"");<br />    }<br />
Copy after login

请注意 是[false] 不是false
因为前面应需要加了[]

这个是做的转json返回数据的接口 while循环那里若有优化的写法也请指教
现在就是因为这个 若不符合返回的会是[false] 试着用和false一样的方法去判断结果都不行
求教这里要怎么写
------解决思路----------------------
    $arrData =array();<br />    while ($$row = mysql_fetch_array($sql_notice))<br />    {<br />       $arrData[] = $row;<br />    }<br />    if($arrData) {<br />      Response::json(200,'success',$arrData);<br />    } <br />.....
Copy after login

我不关心你的目的是什么,只关心你需要什么样的格式

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template