Skip to content

Instantly share code, notes, and snippets.

@udithishara
Forked from felladrin/gspreadsheet.php
Created November 16, 2015 12:09
Show Gist options
  • Save udithishara/961ee62fad23dd4e1d4b to your computer and use it in GitHub Desktop.
Save udithishara/961ee62fad23dd4e1d4b to your computer and use it in GitHub Desktop.
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>";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment