$line){ $total_lines++; } $filename = fopen($xml_file,"r"); for ($i = 0; $i < $total_lines; $i++){ ($data = fgetcsv($filename, 1000, "\t")); $total_fields = count($data); $new_array[] = $data; } fclose ($filename); $keywords = array(); $tags = array(); $vacio = 0; $rec_total = 0; //loop for selecting only data bewteen the tag elements -it starts at the 3rd position and increments by 3 for ($i = 3; $i < $total_lines; $i+=3){ //$keywords[] = $new_array[$i][0]; $temp = $new_array[$i][0]; $temp = str_replace(";", "", $temp); $temp = str_replace("", ".", $temp); $temp = str_replace("", "", $temp); $temp = str_replace("", "", $temp); $temp = str_replace(" & ", " and ", $temp); if ($temp !== ".") { $keywords[] = $temp; } else{$vacio++;} //$keywords[] = $temp; $rec_total++; } $total = count($keywords); //print_r($keywords); foreach($keywords as $keyword) { $words = explode(";", $keyword); $words = str_replace("&", "", $words); foreach($words as $word) { $word = strtolower($word); $word = ltrim($word); if ((isset($tags[$word])) and ($tags[$word]!==" ")) { $tags[$word] += 1; } else { $tags[$word] = 1; } } } ksort($tags); // sort by key a,b...z -important for display //begin editing as_content.js file $myFile = "as_content.js"; $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = "function createAutoComplete() {\n"; fwrite($fh, $stringData); $stringData = "var aNames = [\n"; fwrite($fh, $stringData); $tags = array_keys($tags); //print_r($tags); foreach ($tags as $value) { $stringData = "\"" . $value . "\", \n"; fwrite($fh, $stringData); } $stringData = "];\n"; fwrite($fh, $stringData); $stringData = "new autoComplete(aNames,document.getElementById('txt'),document.getElementById('suggest'),10);\n"; fwrite($fh, $stringData); $stringData = "}"; fwrite($fh, $stringData); fclose($fh); //end editing as_content.js file ?> AutoSuggest for CONTENTdm

file: as_content.js created!



A search box with AutoSuggest