how to know whether key exists in Json string [duplicate]

IF you want to also check if the value is not null you can use isset

if( isset( $mydata['user_id'] ) ){
   // do something
}

i.e. the difference between array_key_exists and isset is that with

$json = {"user_id": null}

array_key_exists will return true whereas isset will return false

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)