function getIndexTag($patern, $filename) { $f = get_file_utf8($filename); if (trim($f[0]) <> $patern) return "invalid patern"; $f[0] = ""; while(list($key, $line) = each($f)) { $line = trim($line); if (substr($line, 0, 1) == "[") { $file = trim(substr($line, 1, -1)); $base[$file] = array(); } else if (ereg("^#", $line)) echo "\n".$line; else if ($line <> '') { list($field, $value) = explode("=", $line); $field = trim($field); $value = trim($value); $base[$file][$field] = $value; } } return $base; } example: $src = "myindex.txt"; print_r(getIndexTag("\\Swac_Index_Tags", $src));