0

This may end up being a trivial question - I know I'm going to need to do this soon for an app I'm working on, but haven't really worked on it myself yet - I'm really just floating it to see if there's an obvious method I'm missing.

Basically, what I need is to generate a sequence of numbers using a-z, A-Z, 0-9, except without vowels. There is a small chance I will need to make it unpredictable, so being able to generate out of order is a bonus.

I'm initially thinking for each new one to just work forward from the last no-vowel match until I find the next one (or generate random numbers until I get one I don't have already in the case of unpredictable values), but is there a better way? Perhaps a baseX number system obj that allows you to specify the allowable characters?

Using PHP/MySQL if it matters.

Eli
  • 97,462
  • 20
  • 76
  • 81

1 Answers1

1

There's a function in an answer of mine here that can convert from any base to any other and which lets you customize the digit pool; it also works on arbitrary-sized input. You can generate a sequence in base 10 and convert to whatever you need.

Community
  • 1
  • 1
Jon
  • 428,835
  • 81
  • 738
  • 806
  • That's perfect, thanks! I'll be tweaking it and making it part of my core id generator =o) – Eli Mar 21 '12 at 01:27