richardjh Posted December 15, 2007 Share Posted December 15, 2007 Hello again, I need some help tweaking this function so that i can add more than one word to the 'tag' field in my sql database. This function is from a tag cloud script i found on the internet and i have managed to link it to my db. However, it currently queries the db and returns tag words 'singular' - I mean i have to have one tag per row. I want to add tags using comma separators and then have this function (below) explode the comma separated list and then populate the array. I have tried (honest) but alas it has beaten me. This is the function: function get_tag_cloud() { // Default font sizes $min_font_size = 12; $max_font_size = 30; // Pull in tag data $tags = get_tag_data(); $minimum_count = min(array_values($tags)); $maximum_count = max(array_values($tags)); $spread = $maximum_count - $minimum_count; if($spread == 0) { $spread = 1; } $cloud_html = ''; $cloud_tags = array(); // create an array to hold tag code foreach ($tags as $tag => $count) { $size = $min_font_size + ($count - $minimum_count) * ($max_font_size - $min_font_size) / $spread; $cloud_tags[] = '<a style="font-size: '. floor($size) . 'px' . '" class="tag_cloud" href="http://www.google.com/search?q=' . $tag . '" title="\'' . $tag . '\' returned a count of ' . $count . '">' . htmlspecialchars(stripslashes($tag)) . '</a>'; } $cloud_html = join("\n", $cloud_tags) . "\n"; return $cloud_html; } So this function works wonderful if the 'tag' field in my database contains a single word. If i add more than one word for instance 'tag, tag2, tag3' it will show those three words as one. Thus i really want to explode then and populate the tag cloud with three separate words. hope I've explained well enough for someone to help me suss where the hell i place my 'explode' function. thanks gents Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.