我有这个JSON
{
"code": "1",
"message": "User Created",
"data": {
"name": "Customer Name",
"email": "customer@email.com"
}
}
如何使用PHP获取姓名和电子邮件?
答案 0 :(得分:2)
$json_str = '{
"code": "1",
"message": "User Created",
"data": {
"name": "Customer Name",
"email": "customer@email.com"
}
}';
$arr = json_decode($json_str, true);
echo $arr['data']['name'];
echo $arr['data']['email'];