0

i'm having a issue decoding a array from a API and was wondering if anyone could help me out.

{
"status": "200",
"response": {
    "onlineId": "psn",
    "plus": 0
}

I'm trying to echo the 'plus'

$hasplus = json_decode(file_get_contents("http://tusticles.com/psn/api?psn=".$id)) -> {'response->plus'};

Does anyone know why it's not working, also i'm still learning and fairly new to PHP. Thanks

SevnDK
  • 31
  • 8
  • `->response->plus` (without brackets and single quotes) – fusion3k Apr 07 '16 at 22:29
  • Like this? `$hasplus = json_decode(file_get_contents("http://tusticles.com/psn/api?psn=".$id)) -> response->plus;` – SevnDK Apr 07 '16 at 22:31
  • I fixed it, thank you dude! :) – SevnDK Apr 07 '16 at 22:32
  • It doesn't matter from where you get the json. Json is json no matter how you get it. When you decode it look at the structure you get with `print_r(json_decode($json));`. Then you see how you have to access the data. – Rizier123 Apr 07 '16 at 22:32

0 Answers0