How to convert JSON to a string in PHP?

In PHP, you can use the json_encode() function to convert JSON to a string.

Here is an example:

$json = '{"name":"John", "age":30, "city":"New York"}';
$obj = json_decode($json);

// 将JSON转换为字符串
$str = json_encode($obj);

echo $str;

The output is:

{"name":"John", "age":30, "city":"New York"}
bannerAds