public function getResults($response)
    {
        $results = array('rows' => array());

        for ($report_index = 0; $report_index < count($response); $report_index++) {

            $report = $response[$report_index];
            $header = $report->getColumnHeader();

            $dimension_headers = $header->getDimensions();
            $metric_headers = $header->getMetricHeader()->getMetricHeaderEntries();
            $rows = $report->getData()->getRows();

            for ($row_index = 0; $row_index < count($rows); $row_index++) {

                $row = $rows[$row_index];
                $dimensions = $row->getDimensions();
                $metrics = $row->getMetrics();

                for ($i = 0; $i < count($dimension_headers) && $i < count($dimensions); $i++) {
                    $results['rows'][$row_index][$dimension_headers[$i]] = $dimensions[$i];
                }

                for ($j = 0; $j < count($metrics); $j++) {
                    $values = $metrics[$j]->getValues();
                    for ($k = 0; $k < count($values); $k++) {
                        $entry = $metric_headers[$k];
                        $results['rows'][$row_index][$entry->getName()] = $values[$k];
                    }
                }
            }
        }

        return $results;
    }
public function getResults($response)
    {
        $results = array('rows' => array());

        for ($report_index = 0; $report_index < count($response); $report_index++) {

            $report = $response[$report_index];
            $header = $report->getColumnHeader();

            $dimension_headers = $header->getDimensions();
            $metric_headers = $header->getMetricHeader()->getMetricHeaderEntries();
            $rows = $report->getData()->getRows();

            for ($row_index = 0; $row_index < count($rows); $row_index++) {

                $row = $rows[$row_index];
                $dimensions = $row->getDimensions();
                $metrics = $row->getMetrics();

                for ($i = 0; $i < count($dimension_headers) && $i < count($dimensions); $i++) {
                    $results['rows'][$row_index][$dimension_headers[$i]] = $dimensions[$i];
                }

                for ($j = 0; $j < count($metrics); $j++) {
                    $values = $metrics[$j]->getValues();
                    for ($k = 0; $k < count($values); $k++) {
                        $entry = $metric_headers[$k];
                        $results['rows'][$row_index][$entry->getName()] = $values[$k];
                    }
                }
            }
        }

        return $results;
    }
public function getResults ( $ response ) { $ results = array ( 'rows' => array ( ) ) ; for ( $ report_index = 0 ; $ report_index < count ( $ response ) ; $ report_index ++ ) { $ report = $ response [ $ report_index ] ; $ header = $ report -> getColumnHeader ( ) ; $ dimension_headers = $ header -> getDimensions ( ) ; $ metric_headers = $ header -> getMetricHeader ( ) -> getMetricHeaderEntries ( ) ; $ rows = $ report -> getData ( ) -> getRows ( ) ; for ( $ row_index = 0 ; $ row_index < count ( $ rows ) ; $ row_index ++ ) { $ row = $ rows [ $ row_index ] ; $ dimensions = $ row -> getDimensions ( ) ; $ metrics = $ row -> getMetrics ( ) ; for ( $ i = 0 ; $ i < count ( $ dimension_headers ) && $ i < count ( $ dimensions ) ; $ i ++ ) { $ results [ 'rows' ] [ $ row_index ] [ $ dimension_headers [ $ i ] ] = $ dimensions [ $ i ] ; } for ( $ j = 0 ; $ j < count ( $ metrics ) ; $ j ++ ) { $ values = $ metrics [ $ j ] -> getValues ( ) ; for ( $ k = 0 ; $ k < count ( $ values ) ; $ k ++ ) { $ entry = $ metric_headers [ $ k ] ; $ results [ 'rows' ] [ $ row_index ] [ $ entry -> getName ( ) ] = $ values [ $ k ] ; } } } } return $ results ; }
Returns an array of results from the response object
@param \Google_Service_AnalyticsReporting_GetReportsResponse $response
@return array
Returns an array of results from the response object