14862875 Posted May 19, 2009 Share Posted May 19, 2009 I'm trying to create a tag 'cloud' constructor, i have already coded the form as well as some of my index.php page. i have no idea on how to go about creating this cloud..seeing that i have never worked with tags before..your help would be much appreciated <?php session_start(); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Tag Cloud Constructor</title> </head> <body bgcolor="black"> <center> <br/><br/> <table border="0"> <tr> <td background='bike.jpg' width='710' height='490' valign='top' style="text-align:left;color:white;font-family:tahoma;font-size:12;border:1 solid white;padding:20px;"> <span style="font-size:35">Tag Cloud Constructor</span><br/><br/><br/> <?php if(isset($_POST['submitted'])) { if(!strlen(trim($_POST['text']))) { print "<span style='color:red;font-weight:bold;'>Please enter some text!!</span><p/>"; include('form.php'); } else { //format text $cloud_one_text=$_POST['text']; $cloud_one_text=strtolower(stripslashes($cloud_one_text)); $cloud_one_text=ereg_replace('[^a-zA-Z ]+', '', $cloud_one_text); //remove stopwords $stopwords=array("a", "about", "above", "above", "across", "after", "afterwards", "again", "against", "all", "almost", "alone", "along", "already", "also","although","always","am","among", "amongst", "amoungst", "amount", "an", "and", "another", "any","anyhow","anyone","anything","anyway", "anywhere", "are", "around", "as", "at", "back","be","became", "because","become","becomes", "becoming", "been", "before", "beforehand", "behind", "being", "below", "beside", "besides", "between", "beyond", "bill", "both", "bottom","but", "by", "call", "can", "cannot", "cant", "co", "con", "could", "couldnt", "cry", "de", "describe", "detail", "do", "done", "down", "due", "during", "each", "eg", "eight", "either", "eleven","else", "elsewhere", "empty", "enough", "etc", "even", "ever", "every", "everyone", "everything", "everywhere", "except", "few", "fifteen", "fify", "fill", "find", "fire", "first", "five", "for", "former", "formerly", "forty", "found", "four", "from", "front", "full", "further", "get", "give", "go", "had", "has", "hasnt", "have", "he", "hence", "her", "here", "hereafter", "hereby", "herein", "hereupon", "hers", "herself", "him", "himself", "his", "how", "however", "hundred", "ie", "if", "in", "inc", "indeed", "interest", "into", "is", "it", "its", "itself", "keep", "last", "latter", "latterly", "least", "less", "ltd", "made", "many", "may", "me", "meanwhile", "might", "mill", "mine", "more", "moreover", "most", "mostly", "move", "much", "must", "my", "myself", "name", "namely", "neither", "never", "nevertheless", "next", "nine", "no", "nobody", "none", "noone", "nor", "not", "nothing", "now", "nowhere", "of", "off", "often", "on", "once", "one", "only", "onto", "or", "other", "others", "otherwise", "our", "ours", "ourselves", "out", "over", "own","part", "per", "perhaps", "please", "put", "rather", "re", "same", "see", "seem", "seemed", "seeming", "seems", "serious", "several", "she", "should", "show", "side", "since", "sincere", "six", "sixty", "so", "some", "somehow", "someone", "something", "sometime", "sometimes", "somewhere", "still", "such", "system", "take", "ten", "than", "that", "the", "their", "them", "themselves", "then", "thence", "there", "thereafter", "thereby", "therefore", "therein", "thereupon", "these", "they", "thickv", "thin", "third", "this", "those", "though", "three", "through", "throughout", "thru", "thus", "to", "together", "too", "top", "toward", "towards", "twelve", "twenty", "two", "un", "under", "until", "up", "upon", "us", "very", "via", "was", "we", "well", "were", "what", "whatever", "when", "whence", "whenever", "where", "whereafter", "whereas", "whereby", "wherein", "whereupon", "wherever", "whether", "which", "while", "whither", "who", "whoever", "whole", "whom", "whose", "why", "will", "with", "within", "without", "would", "yet", "you", "your", "yours", "yourself", "yourselves", "the"); $cloud_one_text=preg_replace('/\b('.implode("|",$stopwords).')\b/i', '', $cloud_one_text); //extract words $cloud_one_words=explode(' ',$cloud_one_text); $cloud_one_word_count=count($cloud_one_words); if ($cloud_one_word_count<100) { print"<span style='color:red;font-weight:bold;'> You must enter atleast 100 words!</span><p/>"; include('form.php'); } else { print"Thanks for entering the required amount of words"; $count_words = array_count_values($cloud_one_words); } } } else { include('form.php'); } ?> </body> </html> Your tag cloud will always consist of 20 tags which must be sorted alphabetically. If the user entered 150 words, you have to select the 20 words which occurred most and display these in your cloud. below is a screenshot of how it should look [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/158749-help-please/ Share on other sites More sharing options...
mrMarcus Posted May 19, 2009 Share Posted May 19, 2009 you should check out this thread .. http://www.phpfreaks.com/forums/index.php/topic,252765.0.html .. might be what you're looking for. Link to comment https://forums.phpfreaks.com/topic/158749-help-please/#findComment-837270 Share on other sites More sharing options...
radi8 Posted May 19, 2009 Share Posted May 19, 2009 Another reference is (in addition to mrMarcus): http://www.lotsofcode.com/php/tag-cloud-v2.htm. This is a cool demo and is very complete. Link to comment https://forums.phpfreaks.com/topic/158749-help-please/#findComment-837318 Share on other sites More sharing options...
14862875 Posted May 19, 2009 Author Share Posted May 19, 2009 I don't know how to use that code and implement it with my own Link to comment https://forums.phpfreaks.com/topic/158749-help-please/#findComment-837428 Share on other sites More sharing options...
Haroskyline Posted May 19, 2009 Share Posted May 19, 2009 I don't know how to use that code and implement it with my own Just play with it for awhile. Link to comment https://forums.phpfreaks.com/topic/158749-help-please/#findComment-837512 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.