Home php Work with STDClass Object ()

Work with STDClass Object ()

Author

Date

Category

There is a variable $ places, where the object is stored:

stdclass object ([row1] = & gt; 1 [seet1] = & gt; 3 [row2] = & gt; 1 [SEET2] = & GT; 4)

How can I disable / save to a variable specific part of the object?
I tried it, but it does not work

echo $ places ['seet1'];

and how to output the number of items? I tried it, but displays only 1:

echo count ($ places);

Answer 1

Well, the same object, investigate and handle it needed as with the object:

echo $ places- & gt; seet1;

To use Count (), you can use get_object_vars () , or if for some reason this option does not fit, then convert an object into an array:

// Option 1
ECHO COUNT (GET_OBJECT_VARS ($ Places));
// Option 2
Echo Count ((Array) $ places);

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions