Chuyển array thành json string
$user = [
'id' => 1,
'username' => 'admin',
];
echo json_encode($user);
Kết quả:
{"id":1,"username":"admin"}
Nếu muốn format đẹp hơn ta cho thêm tham số…
https://tranhoangphucdev.blogspot.com/2020/06/lam-viec-voi-json-trong-php.html
#json #php