0

I have this JSON

{
    "code": "1",
    "message": "User Created",
    "data": {
        "name": "Customer Name",
        "email": "customer@email.com"
    }
}

How do I get the name and email here using PHP?

Mr X
  • 129
  • 2
  • 16
n00b
  • 192
  • 13

1 Answers1

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'];
Kita
  • 2,604
  • 19
  • 25