From 6b15ec70ec0e246b0f7a6e4cfa52bddadb971e95 Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Tue, 10 Jul 2012 09:42:07 +0000 Subject: allow nonmatching colcount in cols() --- it_pipe.class | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'it_pipe.class') 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; } -- cgit v1.2.3