php is variable an array or object
Use is_array
to check if a variable is an array, and similarly, use is_object
to check if a variable is an object.
Try to use:
if (!is_scalar($var)) {
// Varible is object or array
}
object (use is_object)-----
stdClass Object
(
[rest_food_items_id] => 137
[rest_user_id] => 42
)
array (use is_array)----
Array
(
[rest_food_items_id] => 137
[rest_user_id] => 42
)
**
Example
**
if(is_object($data)){
}
if(is_array($data)){
}