I am using json_encode to convert my multidimensional php array to json output. Typically, this function converts all values ββto strings. To make sure that integer values ββare sent to javascript as integer values, I use a numerical check:
$json = json_encode($data, JSON_NUMERIC_CHECK);
This works great in all cases except one for my application. In the php array (which is retrieved from the database) there is one field containing very large integers. I save it in the database as VARCHAR, but unfortunately it converts to an integer when encoded in json. The problem is that since it is a very large integer, it is rounded and therefore does not reflect the true value. How could I solve this problem?
Bjorn source share