row data (php)

The main data returned from the API is returned as a 2-dimensional List of strings. The outer list represents all the rows of data. Each inner list represents a single row, where the order of cells in a row is same as the fields in the column header object described above. Since data in each cell is returned as a string, the DataType field in each column header object is particularly useful since it can be used to parse string values into an appropriate type. See the reference guide here: https:developers.google.comanalyticsdevguidesreportingcorev3reference#response_fields for all the possible data types. The following examples print both the headers and rows of the table.

private printDataTable(&$results) {
  if (count($results->getRows()) > 0) {
    $table .= \'\';

     Print headers.
    $table .= \'\';

    foreach ($results->getColumnHeaders() as $header) {
      $table .= \'\';

     Print table rows.
    foreach ($results->getRows() as $row) {
      $table .= \'\';
        foreach ($row as $cell) {
          $table .= \'\';
    }
    $table .= \'
\' . $header->name . \'\'; } $table .= \'
\' . htmlspecialchars($cell, ENT_NOQUOTES) . \'\'; } $table .= \'
\'; } else { $table .= \'

No Results Found.

\'; } print $table; }