php - Distinguish between not set at all AND null? -


$record['field'] = null;  if (isset($record['field']) || is_null($record['field'])) {   // when $record['field'] set , not null, or, when $record['field'] = null   // basically, when $record['field'] defined $record['field'] = whatever, null. } else {   // when $record['field'] not defined @ all, not null } 

my intention check if $record['field'] defined @ all, null.

however every time $record['field'] not set @ (e.g. comment out $record['field'] = null;), gives me error:

undefined index: field 

in case ask, when null values become meaningful, such in sql query assigning null value timestamp column make mysql update current timestamp.

any way can this?

since have here not variable associative array, can use array_key_exists() check array contains field name, regardless of value.


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -