Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5938079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:38:01+00:00 2026-05-22T15:38:01+00:00

I am trying to create a simple tag cloud in PHP. The following is

  • 0

I am trying to create a simple tag cloud in PHP. The following is what I have so far but its not working because I have no idea what I’m doing.

For each record in the database, tags are stored like this: tag1,tag2,tag3 etc… So I have to somehow get the records first and them break then into individual tags and display them that way. Any help would be greatly appreciated.

// DB: get snippet tags
$get_snippet_tags = mysqli_query($conn, "SELECT Tags FROM snippets WHERE IsPublic = 1 LIMIT 20")
or die($dataaccess_error);

if(mysqli_num_rows($get_snippet_tags) > 0 )
{
    while($row = mysqli_fetch_array($get_snippet_tags))
    {
        $snippet_tags = $row['Tags'];

        // explode tags
        $tags_array = array_map('string', $snippet_tags);
        $cloud_tag = implode(", ", $tags_array);

        // echo out resluts
        echo '<a href="#">'.$tags_array.'</a>';
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T15:38:02+00:00Added an answer on May 22, 2026 at 3:38 pm

    begin by using

    explode('separator','string'); like explode(',',$row['Tags']);
    

    this will make your string in to an array separated by ‘,’.

    push each array you get (from explode) to an array.

    then create a function like:

     function value_occurs($arr) { 
          $arr2=array(); 
          if(!is_array($arr['0'])){$arr=array($arr);} 
             foreach($arr as $k=> $v){ 
                foreach($v as $v2){ 
                   if(!isset($arr2[$v2])){ 
                       $arr2[$v2]=1; 
                   }else{ 
                       $arr2[$v2]++; 
                } 
             } 
         } 
         return $arr2; 
     }
    

    and call it

    $result = value_occurs($theArrayWithAllTheTags);<br>
    

    this will return an array with your tagname as key and your count as value

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is simple, but not working. I am trying to create a temp file
I'm trying to create a simple BaSH-like grammar on ANTLRv3 but haven't been able
I'm new to postgreSQL and I have a simple question: I'm trying to create
I'm trying to use sIFR to create a tag cloud effect for a homepage
I'm trying to create a simple search form in Rails, but I think I'm
I'm trying, in vain, to create a simple Django template tag to either show
I am trying to create simple user registration form. I have an index.html file
Hi I am trying to write a tag cloud using jquery xml+MySql and php.
I'm trying to create a simple app that draws rectangles within the Canvas tag.
I have been trying to create a simple app that parse an entire channel

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.