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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:37:58+00:00 2026-06-09T22:37:58+00:00

I need to generate a sequence (or function to get a next id) with

  • 0

I need to generate a sequence (or function to get a “next id”) with an alphanumeric incrementor.

The length of the string must be defineable, and the Characters must be 0-9, A-Z.

So for example, with a length of 3:

000
001
002
~
009
00A
00B
~
00Z
010
011
etc..

So I imagine the function might be used like this:

$code = '009'
$code = getNextAlphaNumeric($code);
ehco $code; // '00A'

I’m working on a solution to this myself, but curious if anyone has tackled this before and come up with a smarter / more robust solution than my own.

Does anyone have a nice solution to this problem?

  • 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-09T22:37:59+00:00Added an answer on June 9, 2026 at 10:37 pm

    Would something like base_convert work? Maybe along these lines (untested)

    function getNextAlphaNumeric($code) {
       $base_ten = base_convert($code,36,10);
       return base_convert($base_ten+1,10,36);
    }
    

    The idea is that your codes are all really just a base 36 number, so you convert that base 36 number to base 10, add 1 to it, then convert it back to base 36 and return it.

    EDIT: Just realized that there may be an arbitrary string length of the code, but this approach might still be doable — if you capture all the leading zeroes first, then strip them off, do the base 36 -> base 10 conversion, add one, and add back any needed leading zeroes …

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

Sidebar

Related Questions

I need to generate unique non-sequential alphanumeric string of exactly length 6 (not less,
I need to generate such pattern for my input, for example: +375 29 911-91-91
I'm trying to generate a sequence table in MySQL, so that I can get
I need to generate a controlled sequence of pseudo-random numbers, given an initial integer
I need to generate every combination of a sequence of digits where each digit
I need to generate a program that generates the Fibonacci Sequence Here is what
I need to generate Sequence Diagram for my project. I have made the classes,
I need to generate a (pseudo) random sequence of N bit integers, where successive
I have a need to assign the next sequence number for a Project according
I am working on something where I need to generate the sequence 1,2,3...a,b,c,d...z,11,12,13...aa,ab,ac...zzzzzzzz, using

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.