function googleSearch(\GoogleSearch &$google, $offset = 0, $userTotal = 200) { try { $sites = array(); $total = 0; do { $result = $google->doGoogleSearch(); $google->setStart($offset); if ($result->responseData->cursor->estimatedResultCount) { $total = $result->responseData->cursor->estimatedResultCount - $offset; if ($userTotal == 0) { $userTotal = $total; } } foreach ($result->responseData->results as $searchResult) { $url = $searchResult->visibleUrl; if (!in_array($url, $sites)) { $sites[] = $url; } } $offset += 8; } while ($offset < $total && $offset < $userTotal); } catch (Exception $e) { $google->log($e->getMessage(), 1, "red"); return $sites; } return $sites; }