'tags'/*, 'testimonials_content' => 'tags'*/); //use additional if joining tags from multiple sections foreach($sectionsToField as $sectionName => $fieldName) { //get section records $records = mysql_select($sectionName); foreach ($records as $record) { //turn field into an array of values $tags = explode(",", @$record[$fieldName]); // add tags to the count array foreach ($tags as $tag) { $tag = trim($tag); if (!$tag) { continue; } // skip empty array values if (array_key_exists($tag, $tagsToCount)) { $tagsToCount[$tag]++; } else { $tagsToCount[$tag] = 1; } } } } //PHP doesn't have a shuffle function built in that maintains keys, but this version does. function shuffle_assoc($list) { if (!is_array($list)) return $list; $keys = array_keys($list); shuffle($keys); $random = array(); foreach ($keys as $key) { $random[] = $list[$key]; } return $random; } ?>