2010/06/16
php | parseGoogleSpreadsheets
クラウドというか、簡単なコンフィグの共有にGoogleのエクセルを使う。
$items = parseGoogleSpreadsheets('キー文字列');
print_r($items);
function parseGoogleSpreadsheets($key){
$txt = file_get_contents("http://spreadsheets.google.com/pub?key=$key&output=txt");
$rows = explode("\n",$txt);
$headers = explode("\t",trim(array_shift($rows)));
$items = array();
forEach($rows as $row){
$cells = explode("\t",trim($row));
$item = array();
forEach($cells as $i => $cell){
$item[$headers[$i]] = $cell;
}
$items[] = $item;
}
return $items;
}