-
-
Save udithishara/961ee62fad23dd4e1d4b to your computer and use it in GitHub Desktop.
Listing Google Spreadsheet answers with PHP (Parsing JSON)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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