在PHP中,可以使用json_encode()函數(shù)將JSON數(shù)據(jù)轉(zhuǎn)換為字符串。以下是一個(gè)示例:
$data = array(
'name' => 'John',
'age' => 30,
'city' => 'New York'
);
$json = json_encode($data);
echo $json;
輸出結(jié)果將是一個(gè)表示JSON數(shù)據(jù)的字符串:
{"name":"John","age":30,"city":"New York"}