content); foreach ($tag_array as $tag) { $tags[] = strtolower($tag[0]); // Also convert all tags to lower case } } if(!empty($tags)) { natcasesort($tags); $tag_count = array_count_values($tags); //arsort($tag_count, SORT_STRING); //ksort($tag_count, SORT_STRING); //strnatcasecmp($tag_count); $max_count = max($tag_count); $min_font_size = 10; $max_font_size = 30; $num_intermediate_levels = 1; $font_size_interval = ($max_font_size - $min_font_size) / ($num_intermediate_levels + 1); // Get current URI to keep the `?profile=URL` as the base for links to tags $uri = $_SERVER['REQUEST_SCHEME'].'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; // Remove existing `(?|&)search=word` params from base URI // https://stackoverflow.com/a/4937540 $uri = preg_replace('/.search=\w+&?/', '$1', $uri); // Get active tag, if any $active_tag = ""; if (!empty($_GET['search'])) { $active_tag = $_GET['search']; } foreach ($tag_count as $tag => $count) { $font_size = $min_font_size + ($count / $max_count) * $font_size_interval; $tag = str_replace('#', '', $tag); if ($tag === $active_tag) { echo '#'. $tag .' '; } else { echo '#'. $tag .' '; } //echo '#'. $tag .' ('.$count.') '; } // Detail/summary with top tags and solo tags /* $top_tags = array_filter($tag_count, function($val){return ($val>1);}); $solo_tags = array_diff($tag_count, $top_tags); krsort($solo_tags, SORT_STRING); echo "
Tags: "; foreach ($top_tags as $tag => $count) { $tag = str_replace('#', '', $tag); echo '#'.$tag.' '; } echo ""; foreach ($solo_tags as $tag => $count) { $tag = str_replace('#', '', $tag); echo '#'.$tag.' '; } echo "
"; */ }