something is going wrong , im saving json_encode response in mysql db. it sometimes saving 0
value.im 100% sure that my json_encode function does not receive 0
as a parameter because it always get empty array or associated array, so there is no any chance to receive 0
in parameter.
Problem is that why json_encode returns 0
value sometimes.
i have column type longtext
in db table where im saving its response.
is it issue with character types? like UTF8 or non UTF8?
Here is a code snippet:
$jsonPayload = [];
if (isset($obj['answer']) && (!empty($obj['answer']) || $obj['answer'] == 0)) {
$jsonPayload[$form_fields[$i]->id] = $obj;
}
return json_encode($jsonPayload);