how to check mysql NULL
columns variable with php?
my rows table (example):
1 ---- james ------ italy
2 ---- joyee ------ NULL
my fetch array from table:
$rows[0] = array('name' => 'james', 'country' => 'italy');
$rows[1] = array('name' => 'joyee', 'country' => NULL);
but my problem:
how to check NULL array element:
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?
}
update (var_dump):
'country' => null
Use is_null or === operator.
is_null($row['country'])