summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUrban Müller2012-07-10 09:42:07 +0000
committerUrban Müller2012-07-10 09:42:07 +0000
commit6b15ec70ec0e246b0f7a6e4cfa52bddadb971e95 (patch)
treefceb8a797e4dbdf6247a8d84d2434979bad0e3cf
parent57da96485e0671fc34f2ea862b872af186ff043c (diff)
downloaditools-6b15ec70ec0e246b0f7a6e4cfa52bddadb971e95.tar.gz
itools-6b15ec70ec0e246b0f7a6e4cfa52bddadb971e95.tar.bz2
itools-6b15ec70ec0e246b0f7a6e4cfa52bddadb971e95.zip
allow nonmatching colcount in cols()
-rw-r--r--it_pipe.class11
1 files changed, 10 insertions, 1 deletions
diff --git a/it_pipe.class b/it_pipe.class
index 5e89123..43239b0 100644
--- a/it_pipe.class
+++ b/it_pipe.class
@@ -141,7 +141,16 @@ function cols($collist, $separator = "\t")
{
$keys = explode(",", $collist);
foreach ($this->lines as $idx => $line)
- $this->lines[$idx] = (object)array_combine($keys, explode($separator, $line));
+ {
+ if (count($keys) == count($arr = explode($separator, $line)))
+ $this->lines[$idx] = (object)array_combine($keys, $arr);
+ else
+ {
+ unset($this->lines[$idx]);
+ foreach ($keys as $i => $key)
+ $this->lines[$idx]->$key = $arr[$i];
+ }
+ }
return $this;
}