json decode in php

前端 未结 5 1780
粉色の甜心
粉色の甜心 2020-11-29 11:32

I have the following json string and I want to retrieve just the email address from it. How do I do it in php?

{\"communications\":{\"communication\":[{\"@a         


        
5条回答
  •  旧巷少年郎
    2020-11-29 12:27

    You could use json_decode(). Your example string there is a bit complicated for me to think about right now, but as an example of my own:

    $json = '{"a":"apples","b":["bananas","boysenberries"],"c":"carrots"}';
    
    $arr = json_decode($json);
    echo $arr['a']; // "apples"
    echo $arr['b'][0]; // "bananas"
    

提交回复
热议问题