Far*_*zad 1 php mysql arrays mysqli
如何NULL用php检查mysql列变量?
我的行表(示例):
1 ---- james ------ italy
2 ---- joyee ------ NULL
我从表中获取数组:
$rows[0] = array('name' => 'james', 'country' => 'italy');
$rows[1] = array('name' => 'joyee', 'country' => NULL);
Run Code Online (Sandbox Code Playgroud)
但我的问题:
如何检查 NULL 数组元素:
foreach($rows as $row) {
if ($row['country'] == NULL) echo "country is null"; // not working
if ($row['country'] == '') echo "country is null"; // not working
if (is_null($row['country'])) echo "country is null"; // not working
if (empty($row['country'])) echo "country is null"; // not working
// what is solution? how to check null?
}
Run Code Online (Sandbox Code Playgroud)
更新(var_dump):
'country' => null
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1983 次 |
| 最近记录: |