json_encode The second function parameter is optional and is used to specify encoding options. Here are some commonly used encoding options:
JSON_HEX_QUOTEscape double quotation marks to\u0022。JSON_HEX_TAG: In HTML tags<和>Escape sequence:\u003C和\u003E。JSON_HEX_AMPCharacter:&Escape sequence:\u0026。JSON_HEX_APOSEscape a single quotation mark to\u0027。JSON_NUMERIC_CHECKForces a string-valued number to be converted to a numeric type.JSON_PRETTY_PRINTFormat JSON data for easy readability.JSON_UNESCAPED_UNICODE: Does not encode Unicode characters.JSON_UNESCAPED_SLASHESDo not encode斜杠 characters.JSON_FORCE_OBJECTCast a non-associative array into an associative array.
These options can be used individually or in combination using the bitwise OR operator. | Combined operator usage, e.g.:
$options = JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE;
$jsonString = json_encode($data, $options);