Skip to content

Commit

Permalink
Improve: Sheet::process()
Browse files Browse the repository at this point in the history
  • Loading branch information
mach3 committed Sep 6, 2015
1 parent 76e2d46 commit 1e6b3f4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
sandbox
vendor
composer.lock
*.swp
14 changes: 7 additions & 7 deletions src/Google/Spreadsheet/Sheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,17 @@ private function process($entry){
$this->items = array();

foreach($entry as $col){
$r = ((int) preg_replace("/^[A-Z]+/", "", $col["title"]["\$t"]));
$c = preg_replace("/\d+$/", "", $col["title"]["\$t"]);
preg_match("/^([A-Z]+)(\d+)$/", $col["title"]["\$t"], $m);
$content = $col["content"]["\$t"];
$r = (int) $m[2];
$c = $m[1];
if($r === 1){
$this->fields[$c] = $col["content"]["\$t"];
$this->fields[$c] = $content;
continue;
}
if(! $this->items[$r]){
$this->items[$r] = array();
}
if($this->fields[$c]){
$this->items[$r][$this->fields[$c]] = $col["content"]["\$t"];
$this->items[$r] = is_array($this->items[$r]) ? $this->items[$r] : array();
$this->items[$r][$this->fields[$c]] = $content;
}
}
}
Expand Down

0 comments on commit 1e6b3f4

Please sign in to comment.