1) preg_match_all("/.*?\,/", $variable(где лежит нужный текст), $variable(куда будет вложен текст) );
2) preg_match_all("/\d\d\d\d\-\d\d\-\d\d/", $variable(где лежит нужный текст), $variable(куда будет вложен текст) );
require_once __DIR__ . '/vendor/autoload.php';
function initializeWebmasters(){
$KEY_FILE_LOCATION = __DIR__ . '/service-account.json';
$client = new Google_Client();
$client->setApplicationName("Google Webmasters Hello");
$client->setAuthConfig($KEY_FILE_LOCATION);
$client->setScopes(['https://www.googleapis.com/auth/webmasters.readonly']);
return $client;
}
$webmasters = new Google_Service_Webmasters(initializeWebmasters());
$query = ['запрос'];
$searchTypes = ['web'];
$dataType = ['query','device'];
$enddate = date("Y-m-d",time()-(3*(24*60*60)));
$startdate = date("Y-m-d",time()-(3*(24*60*60)));
$filter = new Google_Service_Webmasters_ApiDimensionFilter();
$filter->setDimension('query');
$filter->setOperator('equals');
$filter->setExpression($query);
$ar_fil_q = new Google_Service_Webmasters_ApiDimensionFilterGroup();
$ar_fil_q -> setFilters( [$filter] );
$webmasters1 = new Google_Service_Webmasters_SearchAnalyticsQueryRequest();
$webmasters1->setStartDate($startdate);
$webmasters1->setEndDate($enddate);
$webmasters1->setSearchType($searchTypes);
$webmasters1->setDimensions($dataType);
$webmasters1->setDimensionFilterGroups( [$ar_fil_q] );
$siteUrl = 'сайт';
$result = $webmasters->searchanalytics->query($siteUrl, $webmasters1) ;
$query = ['запрос'];
$searchTypes = ['web'];
$dataType = ['query'];
//$enddate = date("Y-m-d",time()-(3*(24*60*60)));
//$startdate = date("Y-m-d",time()-(3*(24*60*60)));
$enddate = "2017-03-18";
$startdate = "2017-03-18";
$ar_fil_dimqq = new Google_Service_Webmasters_ApiDimensionFilter();
$ar_fil_dimqq -> setDimension("query");
$ar_fil_dimqq -> setExpression($query);
$ar_fil_q = new Google_Service_Webmasters_ApiDimensionFilterGroup();
$ar_fil_q -> setFilters( $ar_fil_dimqq );
$webmasters1 = new Google_Service_Webmasters_SearchAnalyticsQueryRequest();
$webmasters1->setStartDate($startdate);
$webmasters1->setEndDate($enddate);
$webmasters1->setSearchType($searchTypes);
$webmasters1->setDimensions($dataType);
$webmasters1->setDimensionFilterGroups($ar_fil_q);
$siteUrl = 'сайт';
$result = $webmasters->searchanalytics->query($siteUrl, $webmasters1) ;