I\'m using PHP v5.6.
As i read that php json_encode function is automatically converting int to string. But not in my case. Json_encode is still return it to int not str
json_encode(['code' => 200, 'results' => [id=> strval(1)]]);
With strval() php will return
The string value of var.
In the link posted by Thomas in comments, one user suggests that you do this:
$data = json_encode(array_map('strval', $data));
This might not be the most efficient in terms of performace though, since every entry on the array will pass through the strval
function.