diff options
author | Urban Müller | 2012-07-10 09:42:07 +0000 |
---|---|---|
committer | Urban Müller | 2012-07-10 09:42:07 +0000 |
commit | 6b15ec70ec0e246b0f7a6e4cfa52bddadb971e95 (patch) | |
tree | fceb8a797e4dbdf6247a8d84d2434979bad0e3cf /it_pipe.class | |
parent | 57da96485e0671fc34f2ea862b872af186ff043c (diff) | |
download | itools-6b15ec70ec0e246b0f7a6e4cfa52bddadb971e95.tar.gz itools-6b15ec70ec0e246b0f7a6e4cfa52bddadb971e95.tar.bz2 itools-6b15ec70ec0e246b0f7a6e4cfa52bddadb971e95.zip |
allow nonmatching colcount in cols()
Diffstat (limited to 'it_pipe.class')
-rw-r--r-- | it_pipe.class | 11 |
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; } |