array({no},...), 'subtext'=>{subtext}, 'filename'=>{filename}.pdf, 'title'=>{title}, 'description'=>{description}), * array('category'=>array({no},...), 'subtext'=>{subtext}, 'filename'=>{filename}.pdf, 'title'=>{title}, 'description'=>{description}), * ) */ class TabTextImporter_Helper { public function importFile($filename) { $file = file($filename); $category = array(); $categorymap = array(); $reports = array(); $subtext = ''; foreach($file as $line) { $line = trim($line," \n"); if ($line == '') { $category = array(); $subtext = ''; continue; } if ($line[1] == "\t") { // rapport $line = substr($line, 2); $part = explode("\t",$line); $filename = $part[0].'.pdf'; $title = $part[1]; $description = array_key_exists(2, $part) ? $part[2] : ''; $reports[] = array('category'=>$category, 'subtext'=>$subtext, 'filename'=>$filename, 'title'=>$title, 'description'=>$description); } elseif ($line[0] == "\t") { // subtext $subtext = trim($line); } else { // category $category[] = intval($line); $categorymap[$line] = 1; } } } } ?>