1

This is something I actually haven't come across before. I'm calling which is using the word class in it.

I'm trying to get the JSON object value in PHP like so:

//Deck Class
foreach($json->class as $deckclass){
    $userclass = $deckclass->name;
}

However, $json->class doesn't work as class is a PHP keyword which can't be used.

How can I work around this?

GenesisBits
  • 364
  • 2
  • 23
  • Are you sure? when i test the code it actually works. http://sandbox.onlinephpfunctions.com/code/416aa5f17af677c96c6a4caabd4dbc49d8d812ae What is actually the error message here? – Vitalij Mik Dec 21 '21 at 10:05
  • It should work. What error message you get? How is your `$json` constructed? – Justinas Dec 21 '21 at 10:05
  • Argh. It does work. My code editor was flagging it as an error but it was actually executing correctly. My apologies. – GenesisBits Dec 21 '21 at 10:07

0 Answers0