I like to use form[fieldsdata]
only if it is defined:
$fieldsJson = $data["form[fieldsdata]"] ? $data["form[fieldsdata]"] : "";
But still the error message is:
Notice: Undefined index: form[fieldsdata]
You can either use isset()
to check if it's defined, or (if you're using PHP 7) use the null coalescing operator (??)
$fieldsJson = isset($data["form[fieldsdata]"]) ? $data["form[fieldsdata]"] : "";
$fieldsJson = $data["form[fieldsdata]"] ?? "";
Be aware that using null coalescing will also apply the empty string value if the index exists, but has a null
value.