tags:

views:

61

answers:

4

Hi,

What is the best way to determine if something is an array or an object in PHP? I get a response from a web service and it's either an array or an object depending on how many returned results there are. It is impossible to predict ahead of time how many there will be, so I need to figure out how to process it appropriately. What is the best way to do this?

TIA.

+7  A: 

is_array

Daniel A. White
Well played. JFGI fail on my part. Thanks.
benjy
+7  A: 

Take a look at the is_object and is_array PHP functions.

Garrett
+1  A: 

Try this:

is_array ($var)
Justin Ethier
A: 

is_array()and is_object()

cballou