How to encode a JSON string and convert numeric strings to integers in PHP

1 Answer

0 votes
$array = ['1234', 1234];

echo json_encode($array) . "<br />";
echo json_encode($array, JSON_NUMERIC_CHECK);
                      


/*
run: 
 
["1234",1234]
[1234,1234]
 
*/

 



answered Sep 3, 2017 by avibootz
...