Not sure which database extension you are using. You can try this -
// Fetch the data by executing- "SELEC GROUP_CONCAT(tags) tags FROM my_tags"; // Then explode them $tags = $row['tags']; $tags_array= explode(',', $tags); //Count the values $counts = array_count_values($tags_array); // Sort $counts = arsort($counts);
This is similar to an algorithm. Contribute this with your code.
source share