Return to Snippet

Revision: 57001
at May 2, 2012 09:07 by Felladrin

Initial Code
$key = '0AsfENoKj1ir7dE8yR6U0aUtpdTVNM20wRlNJOhZaclG';
$json_string = file_get_contents("$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];
            echo "<b>$num_column:</b> $a<br/>";
    echo "</p>";

Initial URL

Initial Description
Make your spreadsheet public to get a key like this: 0AsfENoKj1ir7dE8yR6U0aUtpdTVNM20wRlNJOhZaclG

Set it on the script and you're all done.

Initial Title
Listing Google Spreadsheet answers with PHP (Parsing JSON)

Initial Tags
google, json

Initial Language