Q:

Exiting/breaking loop when there is an empty Curl response

So im looping to surveyGizmo, retrieving results. Since they only allow 500 responses per cURL response, I have to keep looping until there is an empty response. So a rough outline of my code looks like this:
    $pageIndex = 1;
    while ($pageIndex) {
        $outputGizmo = getSurveyResponse($method = 'GET', $pageIndex);
            if ($outputGizmo == '') {
                break;
            }

        foreach($outputGizmo->data as $surveyResponse) {
            $firstName = $surveyResponse->{'[question(2)]'};
            $lastName = $surveyResponse->{'[question(10)]'};
            $email = $surveyResponse->{'[question(3)]'};
            $phone = $surveyResponse->{'[question(5)]'};
            $postcode = $surveyResponse->{'[question(6)]'};

            // Add to local database will happen here

        }

        $pageIndex += 1;

    } 

I am getting lost in my loops, and I simply wish to terminate the while loop, when the getSurveyResponse function returns empty. I chose empty because if there are no more responses, it returns literally a blank page.
UPDATE:
object(stdClass)#1 (6) {
 ["result_ok"]=>
bool(true)
 ["total_count"]=>
 string(1) "1"
  ["page"]=>
 string(1) "2"
 ["total_pages"]=>
int(1)
 ["results_per_page"]=>
 string(3) "100"
 ["data"]=>
 array(0) {
 }
}

A:

When no more results are available, what you're getting is not actually an empty string, but an object with limited data. Since an empty response returns the $data property as an array with zero elements, you only need to test empty($outputGizmo->data) to exit your loop:
From your var_dump():
["data"]=>
array(0) {
}

Break when the array is empty. The rest of your code appears as though it will work as is.
if (empty($outputGizmo->data)) {
    break;
}

