In php, would the function count work also on a JSON object? Will it return the number of elements in the object? Or does this function only work for an array?
count($varJSONobject);
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There’s no such thing as a
JSONobjectin PHP (unless it’s some user-defined something or other). There are only arrays orstdClassinstances generated byjson_decodedocs, which can be used withcount.It’s possible to make an object respond to
countby having the object implement theCountabledocs interface.For the sake of completeness, consider the following
countresults: