I'm trying to replace empty field values with NULL, but can't seem to figure out how to do it. I've tried array_map
, array_filter
, and array_walk
, but to no avail. Example:
function replaceWithNull($var)
{
if (empty($var) || $var == ' ') {
$var = "NULL";
}
}
array_walk($_POST, "replaceWithNull");
Instead, it remains empty/blank. What am I missing?