I want to generate a unique alphanumeric string having specific length and having specific characters used. For example I want to create random string having several alphabets initially then some numbers then some alphabets again.
I have an input string $foo which contains both alphanumeric and non-alphanumeric characters.I use ereg_replace to $foo to replace all non-wanted chars with empty chars. Now I want to know what were these "erased" chars. How can I do this?
How can I create unique 10-digit random alphanumeric codes, such as 87i6se3Hfs or 7Gjg668dOh, etc?
I know I probably could have a loop that runs 10 times to get this code, but how can I be sure it's unique everytime? And it should have some kind of a security that keeps people from changing one of two digits/letters to get another valid code. It's like a checksum on your credit card number, I guess.
A user registers the learners details. At this point I use a Random Alphanumeric Generator to return a unique booking reference which is used at the checkout to bring back all the details of their booking. However, sometimes it doesn't seem to work. When I look at the database I see that (in one example) it has generated the same alphanumeric value which is why at the checkout it returns more than what the person thought they had booked. Here's the code for the generator...
I have a variable set as a vary long integer. This integer is unique to the user. What I am trying to do is to cut down on the length of the integer, while still maintaining its uniqueness. I'm thinking somehow converting this number from being numeric (10 characters) to alphanumeric (36 characters) will help me cut this number by more than a third.
I'd like a regexp or other string which can replace everything except alphanumeric chars (a-z and 0-9) from a string. All things such as ,@#$(@*810 should be stripped. Edit: I now need this to strip everything but allow dots, so everything but a-z, 1-9,
How does one remove all non-alphanumeric characters at the end of a string. Eg:
Quick @# brown fox - Quick @# brown fox## Quick @# brown fox Quick @# brown fox @$#
Quick @# brown fox
Seeking to possibly use preg_replace because ereg_replace is deprecated. It could also be tweaked to allow specific non-alphanumeric characters at end of string, eg quotes, exclamation marks, question marks
I am off trying to see if I can create a ticket reservation system, where a visitor should be able to reserve tickets and get a randomized unique alphanumeric string in uppercase letters with a total of 8 characters.
I do not know how to create a script that randomizes letters, from A-Z, and puts it into a string only 8 characters long. To compare it with already stored "randomized" in a database, I guess it is only to do a search in the database.
Anyone who has a good advice or script on how to generate what I would like to achieve?
I've got several strings of the type id1, id2, id125, id1258, etc.What I want to achieve using php is to strip the word "id" from those strings and get only the numbers in integer format in php. How can I do this?
This is for the purpose of having a nice short URL which refers to an md5 hash in a database. I would like to convert something like this:
into something like this:
Those both contain about the same amount of information. The method doesn't have to be direct and reversible but that would be nice (more flexible). At the least I would want a randomly generated string with the hex hash as the seed so it is reproducible. I'm sure there are many possible answers, I am curious to see how people would do it in an elegant way. this doesn't have to have perfect 1:1 correspondence with the original hash but that would be a bonus (I guess I already implied that with the reversibility criteria). And I would like to avoid collisions if possible.
I can't figure out how to optimally do the following in PHP: In a database, I have messages with a unique ID, like 19041985. Now, I want to refer to these messages in a short-url service but not using generated hashes but by simply 'calculate' the original ID. In other words, for example: [URL] should let me calculate the message ID the visitor would like to request.
To make it more obvious, I wrote the following in PHP to generate these 'alphanumeric ID versions' and of course, the other way around will let me calculate the original message ID. The question is: Is this the optimal way of doing this? I hardly think so, but can't think of anything else.