After I query or update the data in the interface, I need to return the data in json format. The problem now is that after processing the returned data through json_encode, some int type data also has quotation marks. I want to put single quotation marks in the int type field value. Remove how to set it, do you need to use regular replacement processing? Solve
After I query or update the data in the interface, I need to return the data in json format. The problem now is that after processing the returned data through json_encode, some int type data also has quotation marks. I want to put single quotation marks in the int type field value. Remove how to set it, do you need to use regular replacement processing? Solve
Also use regular expressions! It's not that troublesome. Can't you just add a parameter directly? JSON_NUMERIC_CHECK
can convert the int type in the array very user-friendly. I definitely didn't read the manual carefully. Reference is as follows
<code>// $array 你要返回的数组 exit(json_encode((array)($array), JSON_NUMERIC_CHECK));</code>
Just set the JSON_NUMERIC_CHECK
parameter
Since PHP is a weakly typed language
Manually traverse formatting
intval
floatval
boolval
strval
Mainly use these functions