How can I determine if something is an array or object in PHP?

What is the best way to determine if something is an array or object in PHP? I get a response from a web service, and it is either an array or an object depending on the number of results returned. It is impossible to predict in advance how much will be, so I need to figure out how to handle it correctly. What is the best way to do this?

TIA.

+3
source share
4 answers
+7
source

Take a look at is_objectand is_arrayPHP functions.

+8
source

:

is_array ($var)
+1

Source: https://habr.com/ru/post/1720024/


All Articles