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 7968367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:03:55+00:00 2026-06-04T07:03:55+00:00

I am creating a ticket system for learning purposes, and I was wondering how

  • 0

I am creating a ticket system for learning purposes, and I was wondering how would I create a simple unique ticket ID that would be similiar to this: gD8f-jxS

It would have 4 characters of random case in the first part

(letters and numbers are allowed, then it would have a dash, and again 3 random letters or numbers of any case.

  • 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-06-04T07:03:56+00:00Added an answer on June 4, 2026 at 7:03 am
    public function generateCode(){
    
        $unique =   FALSE;
        $length =   7;
        $chrDb  =   array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','0','1','2','3','4','5','6','7','8','9');
    
        while (!$unique){
    
              $str = '';
              for ($count = 0; $count < $length; $count++){
    
                  $chr = $chrDb[rand(0,count($chrDb)-1)];
    
                  if (rand(0,1) == 0){
                     $chr = strtolower($chr);
                  }
                  if (3 == $count){
                     $str .= '-';
                  }
                  $str .= $chr;
              }
    
              /* check if unique */
              //$existingCode = UNIQUE CHECK GOES HERE  
              if (!$existingCode){
                 $unique = TRUE;
              }
        }
        return $str;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a small helpdesk ticket control system at work, that would
I have a form that a user would fill out while creating a ticket
I am creating an app that is a ticket sales system. On the checkout
I'm looking at creating a very simple HTML page that contains an HTML form
Creating a simple public/private keypair, such as through ssh-keygen does not create a file
I am creating a tickets opened vs resolved per week gadget that reports back
Creating MVC3 Razor Helper like Helper.BeginForm() says that it can be done using extension
Creating liquid layouts is an immense pain. Now, I totally understand that tables should
i created this ticked some days ago. http://trac.symfony-project.org/ticket/8922#preview I'm interested in creating a patch
I have thought some time about creating a PHP-based customer-service thingy that assigns different

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.