Skip to content
Advertisement

PHP stdClass nested properties

This used to work for me but it no longer does. What’s the new / better methodology for this?

JavaScript

Now I get:

JavaScript

Advertisement

Answer

You need to create the nested object explicitly.

JavaScript

But if you’re just creating JSON, it would be simpler to use associative arrays instead of objects. They can be written as literals easily.

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement