Shoora
11/16/2015 - 12:09 PM

Listing Google Spreadsheet answers with PHP (Parsing JSON)

Listing Google Spreadsheet answers with PHP (Parsing JSON)

<?php
$key = '0AsfENoKj1ir7dE8yR6U0aUtpdTVNM20wRlNJOhZaclG';
$json_string = file_get_contents("https://spreadsheets.google.com/feeds/list/$key/od6/public/values?alt=json");
$obj = json_decode($json_string);
foreach ($obj->{'feed'}->{'entry'} as $entry)
{
    echo "<p>";
    $num_column = 0;
    $answer = explode(', ', $entry->{'content'}->{'$t'});
    foreach ($answer as $a)
    {
        $a = explode(': ', $a);
        if (isset($a[1]))
        {
            $a = $a[1];
            $num_column++;
            echo "<b>$num_column:</b> $a<br/>";
        }
    }
    echo "</p>";
}
?>