How can one differentiate between stdClass objects and arrays when handling data from a webservice in PHP?

When handling data from a webservice in PHP, it is important to differentiate between stdClass objects and arrays to properly access and manipulate the data. One way to differentiate between the two is by using the `is_array()` function to check if the data is an array or not. If the data is not an array, it is likely a stdClass object. This can help you determine the type of data you are working with and handle it accordingly.

$data = getDataFromWebService();

if (is_array($data)) {
    // Data is an array
    foreach ($data as $item) {
        // Process array data
    }
} else {
    // Data is a stdClass object
    // Access object properties using -> notation
    $property = $data->property;
}