Philza Posted May 21, 2009 Share Posted May 21, 2009 His{14862875} code is working but it's prints arrays list not on the cloud. I also need help with his code: <?php $textinform = $_POST['text']; $textinform = stripslashes($textinform); $text = $_POST['text']; $text = stripslashes($text); $text = strtolower($text); $punc = explode(" ",$text); $punc= str_replace(".","",$punc); $punc= str_replace("'","",$punc); $punc= str_replace(":","",$punc); $punc= str_replace("'s","",$punc); $punc= str_replace(";","",$punc); $punc= str_replace(",","",$punc); $punc= str_replace("-","",$punc); $punc= str_replace("!","",$punc); $punc= str_replace("?","",$punc); $counterword=$punc; $punc= array_unique ($punc); sort($punc); if(isset($_POST['submitted'])) { $_SESSION['text']=$_POST['text']; if(!strlen(trim($_POST['text']))) { print "<span style='color:red;font-weight:bold;'>Please enter some text!!</span><p/>"; include('proj_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('proj_form.php'); } else { print "Thanks for entering the required amount of words"; // remove empty words foreach($cloud_one_words as $key => $word) { if(!strlen($word)) { unset($cloud_one_words[$key]); } } $cloud_one_word_occurances = array_count_values($cloud_one_words); print "<pre>"; print_r($cloud_one_word_occurances); print "</pre>"; exit(); } } } else { include('proj_form.php'); } function printTagCloud($tags) { // $tags is the array arsort($tags); $max_size = 32; // max font size in pixels $min_size = 12; // min font size in pixels // largest and smallest array values $max_qty = max(array_values($tags)); $min_qty = min(array_values($tags)); // find the range of values $spread = $max_qty - $min_qty; if ($spread == 0) { // we don't want to divide by zero $spread = 1; } // set the font-size increment $step = ($max_size - $min_size) / ($spread); // loop through the tag array foreach ($tags as $key => $value) { // calculate font-size // find the $value in excess of $min_qty // multiply by the font-size increment ($size) // and add the $min_size set above $size = round($min_size + (($value - $min_qty) * $step)); echo '<a href="#" style="font-size: ' . $size . 'px" title="' . $value . ' things tagged with ' . $key . '">' . $key . '</a> '; } } $text = explode(' ',str_replace(array('\'','the','and','or',',',' '),'',$_POST['the_text_field'])); $tags = new TagCloud($text); echo $tags->get_cloud(); ?> Link to comment https://forums.phpfreaks.com/topic/159051-tag-cloud-constructor/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.