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

  • SEARCH
  • Home
  • 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 287877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:45:55+00:00 2026-05-12T05:45:55+00:00

I have a tag field in my web page, in which user can enter

  • 0

I have a tag field in my web page, in which user can enter tags seprating them by , (comma), same as done in StackOverflow. I am using PHP and I am seprating all tags enetered by the user on the basis of comma using explode function and then adding them to my tags table in teh database.

My code is working perfect for normal tags like if user entered battleship, strategy, sea war then its working, but lets say user enetered battleship, strategy, sea war, or battleship, strategy, games, sea war, , , , , or battleship, strategy, games,, sea war or any wrong value, then how will I detect it and then enter only correct value sin the database.

Is it possible using regExp or any other way, please tell me how?

  • 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-12T05:45:56+00:00Added an answer on May 12, 2026 at 5:45 am
    $tags = "battleship, stragety, ,";
    
    $exp = explode(",", $tags);
    
    $valid_tags = array();
    
    foreach($exp as $tag)
    {
     if( ($tag = trim($tag)) != "")
     {
       $valid_tags[] = $tag;
     }
    }
    

    Will remove whitespace from any tag and if it has any text, tag will be added into valid array 🙂

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

Sidebar

Related Questions

I have an <input> field in my web page, and I want to add
I have a web page that is using the following META tag: <META HTTP-EQUIV=refresh
We have a field 'facet_tag' that contains tags describing a product. Since the tags
I have annotated a String field with @NotEmpty tag. When I try to persist
I have model: # encoding: utf-8 class Tag include Mongoid::Document field :name, type: String
I have XML tag that has the content which is HTML document. <xml-tag> <!--
So I just now learned of the X-Robots-Tag which can be set as part
I 'm new to the asp.net. I have created one web page in that
So what I want is to have a html text field where someone can
I have a schema control having a field named tag (text type) . Now

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.