$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(" & ", " ", $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); $words = str_replace("& ", "", $words); $words = str_replace(";", "", $words); foreach($words as $word) { $word = strtolower($word); //$word = substr_replace($word, '', 0, 1); $word = ltrim($word); if (isset($tags[$word])) { $tags[$word] += 1; } else { $tags[$word] = 1; } } } // begin array display and sorting for top content $total_tags = count($tags); // $limit_tags = 100; arsort($tags); // sort values in reverse order 9,8...0 $tags = array_slice($tags, 1, $limit_tags); // 1: starts at; customize number of top variable ksort($tags); // sort by key a,b...z -important for display // print_r($tags); // end array display and sorting for top content // find array's max an min values $max_qty = max(array_values($tags)); $min_qty = min(array_values($tags)); //find differece $dif = $max_qty - $min_qty; //spread values and create group limits $subgroup = ceil($dif / 10); ?> tag cloud

Displaying top of possible tags



$value) { $size = (($min_size + (($value - $min_qty) * $step))/8); $size = ceil($size); if ($value < ($min_qty + $subgroup)) {$new_font = 1;} elseif ($value < ($min_qty + $subgroup*2)) {$new_font = 2;} elseif ($value < ($min_qty + $subgroup*3)) {$new_font = 3;} elseif ($value < ($min_qty + $subgroup*4)) {$new_font = 4;} elseif ($value < ($min_qty + $subgroup*5)) {$new_font = 5;} elseif ($value < ($min_qty + $subgroup*6)) {$new_font = 6;} elseif ($value < ($min_qty + $subgroup*7)) {$new_font = 7;} elseif ($value < ($min_qty + $subgroup*8)) {$new_font = 8;} elseif ($value < ($min_qty + $subgroup*9)) {$new_font = 9;} elseif ($value < ($min_qty + $subgroup*10)) {$new_font = 10;} $search_tag = str_replace(" ", "%20", $key); ?>  ()