What potential issues can arise when processing API responses in PHP, especially when dealing with single vs multiple entries?

When processing API responses in PHP, a potential issue that can arise is handling single vs multiple entries in the response data. To solve this, you can check if the response contains an array of data or a single object, and then iterate over the entries accordingly to process them correctly.

// Sample API response handling
$response = json_decode($api_response, true);

if (isset($response['data']) && is_array($response['data'])) {
    // Multiple entries
    foreach ($response['data'] as $entry) {
        // Process each entry
    }
} elseif (isset($response['data']) && is_array($response['data'])) {
    // Single entry
    // Process the single entry
} else {
    // Handle error or empty response
}