PHP decoding json

后端 未结 5 1835
误落风尘
误落风尘 2021-01-15 18:58

could anyone here help me with php an decoding json? Im trying to decode a json api url

Here is what I have at the moment:

  $string = \'
    {
              


        
5条回答
  •  一向
    一向 (楼主)
    2021-01-15 19:40

    You can use the curly brackets syntax suggested by Gumbo:

    $json_o->workers->{"someusername.jason-laptop"}
    

    However, the best way (imo, for consistency) is to use the resulting object as an associative array:

    $object = json_decode($string, true);
    
    $object['workers']['bitcoinjol.jason-laptop']['last_share']; // 1307389634
    

提交回复
热议问题